Skip to content

test: use fileURLToPath for the CLI path so spawn works on Windows - #4

Merged
TTigger merged 1 commit into
mainfrom
fix/windows-test-cli-path
Jun 30, 2026
Merged

test: use fileURLToPath for the CLI path so spawn works on Windows#4
TTigger merged 1 commit into
mainfrom
fix/windows-test-cli-path

Conversation

@TTigger

@TTigger TTigger commented Jun 30, 2026

Copy link
Copy Markdown
Owner

What

The three spawn-based test suites (init, roster, try) built the CLI path with:

const CLI = new URL("../src/cli.ts", import.meta.url).pathname;

On Windows, .pathname yields a leading-slash /C:/Users/.../src/cli.ts, which Bun.spawn(["bun", CLI, ...]) cannot launch — so those suites failed deterministically on Windows. CI runs on Linux, where .pathname has 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; no src/ 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.ts failure is a separate root cause: a Bun-on-Windows spawn stdout-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

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>
@TTigger
TTigger merged commit abfd61d into main Jun 30, 2026
1 check passed
@TTigger
TTigger deleted the fix/windows-test-cli-path branch June 30, 2026 06:26
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