test: use fileURLToPath for the CLI path so spawn works on Windows - #4
Merged
Conversation
The three spawn-based suites built the CLI path with
`new URL("../src/cli.ts", import.meta.url).pathname`, which on Windows
yields a leading-slash "/C:/Users/.../src/cli.ts". Bun.spawn can't launch
that, so init/roster/try failed deterministically on Windows (CI is Linux,
where .pathname has no leading slash, so they passed there).
Switch to fileURLToPath(new URL(...)) — correct on both POSIX and Windows.
No src/ change; Linux behaviour is unchanged.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The three spawn-based test suites (
init,roster,try) built the CLI path with:On Windows,
.pathnameyields a leading-slash/C:/Users/.../src/cli.ts, whichBun.spawn(["bun", CLI, ...])cannot launch — so those suites failed deterministically on Windows. CI runs on Linux, where.pathnamehas no leading slash, so they passed there and the bug went unnoticed.Fix
Switch to
fileURLToPath(new URL(...)), which is correct on both POSIX and Windows. Test-only change; nosrc/touched and Linux behaviour is unchanged.Verification
bun run typecheck✅bun test(Windows): 9 deterministic failures → 0; suite goes from 9 fail to 96 pass / 1 fail.Known follow-up (out of scope for this PR)
The remaining intermittent
roster.test.tsfailure is a separate root cause: a Bun-on-Windowsspawnstdout-draining race that occasionally captures an empty string. It is unrelated to the path bug (this fix merely lets the spawns actually run, surfacing the latent race) and is being investigated on its own branch.🤖 Generated with Claude Code