From 62d560a56662b660b0b4d2ab42e74342b15cb905 Mon Sep 17 00:00:00 2001 From: kuanpo Date: Tue, 30 Jun 2026 14:13:42 +0800 Subject: [PATCH] test: use fileURLToPath for the CLI path so spawn works on Windows MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- test/init.test.ts | 5 ++++- test/roster.test.ts | 5 ++++- test/try.test.ts | 5 ++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/test/init.test.ts b/test/init.test.ts index 688db44..577e788 100644 --- a/test/init.test.ts +++ b/test/init.test.ts @@ -3,8 +3,11 @@ import { mkdtemp } from "node:fs/promises"; import { existsSync } from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; +import { fileURLToPath } from "node:url"; -const CLI = new URL("../src/cli.ts", import.meta.url).pathname; +// fileURLToPath (not .pathname) so the path is valid on Windows too — +// .pathname yields a leading-slash "/C:/..." that breaks Bun.spawn. +const CLI = fileURLToPath(new URL("../src/cli.ts", import.meta.url)); interface Run { stdout: string; diff --git a/test/roster.test.ts b/test/roster.test.ts index 687a7e7..b326cee 100644 --- a/test/roster.test.ts +++ b/test/roster.test.ts @@ -3,8 +3,11 @@ import { mkdtemp, mkdir, writeFile } from "node:fs/promises"; import { existsSync } from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; +import { fileURLToPath } from "node:url"; -const CLI = new URL("../src/cli.ts", import.meta.url).pathname; +// fileURLToPath (not .pathname) so the path is valid on Windows too — +// .pathname yields a leading-slash "/C:/..." that breaks Bun.spawn. +const CLI = fileURLToPath(new URL("../src/cli.ts", import.meta.url)); interface Run { stdout: string; diff --git a/test/try.test.ts b/test/try.test.ts index eff831e..e619576 100644 --- a/test/try.test.ts +++ b/test/try.test.ts @@ -3,8 +3,11 @@ import { mkdtemp, mkdir, writeFile } from "node:fs/promises"; import { existsSync } from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; +import { fileURLToPath } from "node:url"; -const CLI = new URL("../src/cli.ts", import.meta.url).pathname; +// fileURLToPath (not .pathname) so the path is valid on Windows too — +// .pathname yields a leading-slash "/C:/..." that breaks Bun.spawn. +const CLI = fileURLToPath(new URL("../src/cli.ts", import.meta.url)); interface Run { stdout: string;