Repository navigation
test: stop the src/node_modules race between platform-binary and the source walk - #695
Conversation
|
@claude /review |
|
Claude finished @theCodeDrift's task in 1m 34s —— View job Review mode: incremental — read 0 prior review thread(s) before reviewing.The only prior content on this PR is the
AssessmentBoth fixes are correct and well-targeted at the race described in #694.
Minor, non-blocking observations:
No correctness, security, or clarity issues found. Production code ( |
Both observations are non-blocking and need no change: the per-directory — AI Coding Agent |
…source walk platform-binary.test.ts planted a fake binary at packages/cli/src/node_modules/.bin to exercise the resolver's node_modules/.bin tier, while api-deprecated-paths.test.ts walked packages/cli/src with a recursive readdir. Run in parallel, the walk could list src/node_modules and then hit ENOENT descending into it after the other test removed it. - platform-binary: relocate the resolver's own module path to a temp directory via a passthrough mock of fileURLToPath, so its `..`/node_modules/.bin computation is still what finds the binary and nothing is written under src/. - api-deprecated-paths: walk by hand, prune node_modules and generated/ before descending, and skip directories or files that vanish mid-walk. Closes #694
255c91b to
43f6493
Compare
Closes #694
What
platform-binary.test.tscreatedpackages/cli/src/node_modules/.binto exercise the resolver'snode_modules/.bintier, whileapi-deprecated-paths.test.tswalkedpackages/cli/srcwith a recursivereaddir. Running in parallel, the walk could listsrc/node_modulesand then throwENOENTdescending into it after the other test removed it.Both sides are fixed:
platform-binary.test.tsno longer writes undersrc/.resolvePlatformBinarylocates the tier relative to its own module (dirname(fileURLToPath(import.meta.url))/../node_modules/.bin). The test now relocates that module path to<tmp>/rules/platform-binary.tsvia a passthroughvi.mock("node:url")(every otherfileURLToPathcall is untouched), plants the fake binary at<tmp>/node_modules/.bin/sg, and asserts the resolver finds it withsource: "node_modules/.bin". The resolver's own path computation is still what is under test, and production code is unchanged.api-deprecated-paths.test.tswalks by hand instead ofreaddir({ recursive: true }), prunesnode_modulesandgenerated/before descending, and skips a directory or file that vanishes between being listed and being read.Verification
pnpm build,pnpm typecheck,pnpm lint: clean.pnpm exec vitest run test/platform-binary.test.ts test/api-deprecated-paths.test.ts20 times in a row: 20/20 pass, andsrc/node_modulesnever appears.api-deprecated-paths.test.ts10 times while a background loop repeatedly created and removedsrc/node_modules/x/y/a.ts: 10/10 pass.pnpm test: 162 files passed, 1 skipped (3163 tests passed, 11 skipped).Changeset
None. This is a test-only change and ships nothing to consumers.
Note
Commits are unsigned by owner decision (GPG key unavailable).