Skip to content

fix(test): lint probe のテストを直列にし、Node.js を .node-version で固定する - #245

Open
masseater wants to merge 1 commit into
mainfrom
fix/lint-probe-tsconfig-race
Open

masseater wants to merge 1 commit into
mainfrom
fix/lint-probe-tsconfig-race

Conversation

@masseater

Copy link
Copy Markdown
Owner

手元の全体の vp test run で tools/checks/builtin-lint.test.ts の 150 行目(effecttsgo の一覧)が expected [] to deeply equal [...] で落ちる問題を直す。

原因

並行に走る lint probe のテストどうしの競合。tsgolint は tsconfig.json の include に合う .ts を列挙してから読むので、その間に別のテストが probe ファイルを消すと typescript(tsconfig-error)(File ... not found)を出し、型を使う診断をすべて落とす。終了コードは 0 で JSON も正しい。

計測 結果
tools/checks に .ts を 20ms ごとに作って消しながら vp lint 12 回 9 回で effecttsgo が消えた
作って消さずに 8 回 8 回とも出た
同じ条件での msa(...)(JS plugin)の診断 8/8 で残る。落ちるのは effecttsgo を見る builtin-lint だけ
main の全体実行で同時にある probe(0.05 秒ごと) 6 本中最大 5 本分

変更

  • checks/*-lint.test.ts を tools-lint-probes project に分け、fileParallelism: false で 1 本ずつ流す。全体実行で同時にある probe は 1 本分になった。
  • lintProbes は tools-lint-probes の外から呼ぶと理由付きで落ちる。vp lint が typescript(tsconfig-error) を返したら、消えたファイル名を付けて落ちる。
  • Node.js を .node-version(26.12.1)で固定する。手元のテストは 26.10.0、CI は engines.node から vp が選んだ 26.12.1 で走っていた。別の版で走ると tools/checks/node-version.test.ts が落ちる。

確かめた結果

手元(darwin-arm64、10 コア)で全体の vp test run を 5 回流し、5 回とも 1601 passed | 58 skipped。

手元の全体の vp test run で builtin-lint.test.ts の 150 行目が `expected [] to deeply equal
[ 'child_process', ... ]` で落ちた。effecttsgo(node-builtin-import) が 1 件も返らなかった。

原因は並行に走る lint probe のテストどうしの競合。tsgolint は tsconfig.json の include に
合う .ts を列挙してから読むので、その間に別のテストが probe ファイルを消すと
typescript(tsconfig-error)「File ... not found」を出し、型を使う診断をすべて落とす。
終了コードは 0 で JSON も正しいので、テストは理由なく期待と食い違う。
- tools/checks に .ts を 20ms ごとに作って消しながら vp lint を 12 回: 9 回で effecttsgo が消えた。
  作って消さないと 8/8 で出る。
- msa(...) の JS plugin の診断は消えない(8/8)。effecttsgo を確かめる builtin-lint だけが落ちる。
- main の全体実行で probe を 0.05 秒ごとに見ると、6 本の probe テストのうち最大 5 本分が同時にあった。
  手元は 10 コアで並行数が多く、重なる時間が長い。版の差ではない(tsgolint は lockfile の 7.0.2003)。

直し方:
- tools の probe テスト(checks/*-lint.test.ts)を tools-lint-probes project に分け、
  fileParallelism: false で 1 本ずつ流す。全体実行で同時にある probe は 1 本分になった。
- lintProbes は tools-lint-probes 以外から呼ぶと理由付きで落ちる。名前を外れた probe テストが
  並行に戻らないようにするため。
- vp lint が typescript(tsconfig-error) を返したら、消えたファイル名を付けて落とす。
  手元で同じ checkout を触る別の作業と重なっても、黙って食い違わない。
- probe を tsconfig の exclude に入れる案は取らない。外すと推論 project になり compilerOptions が
  効かず、TS2591 が出て effecttsgo の文言も変わる。

あわせて Node.js を .node-version(26.12.1)で固定する。手元のテストは mise の 26.10.0、CI は
engines.node(>=26.0.0)から vp が選んだ 26.12.1 で走っていた。builtin-lint は動いている Node の
fs の *Sync 一覧と突き合わせるので、版がずれると手元と CI で結果が分かれる。vp・setup-vp・mise は
.node-version を読む。テストは別の版で走ると落ちる。

手元で全体の vp test run を 5 回流し、5 回とも通った(1601 passed | 58 skipped)。
masseater added a commit that referenced this pull request Oct 25, 2026
PR #245 は lintProbes を tools-lint-probes の project(checks/*-lint.test.ts)からだけ呼べるようにする。
lint probe を使う試作のテストのうち、class-reach-boundary・schema-tagged-error-probe・typed-access の
3 本はこの名前に合っていなかったので、#245 の後もその project で直列に走るよう名前を変えた。
中身は変えていない。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant