diff --git a/browse/test/claude-bin.test.ts b/browse/test/claude-bin.test.ts index 25aee32c..0b9d7eb9 100644 --- a/browse/test/claude-bin.test.ts +++ b/browse/test/claude-bin.test.ts @@ -40,10 +40,14 @@ describe('claude-bin', () => { test('PATH-resolvable override goes through Bun.which (the bug the fork shipped)', () => { // Make a fake binary in a temp dir, point PATH at it, set override to bare command name. + // Windows requires the file to have a PATHEXT-listed extension to be discoverable + // via Bun.which — without the extension Bun.which returns undefined. const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'claude-bin-test-')); - const fakeBin = path.join(tmpDir, 'fake-claude-cli'); - fs.writeFileSync(fakeBin, '#!/bin/sh\necho fake\n'); - fs.chmodSync(fakeBin, 0o755); + const isWindows = process.platform === 'win32'; + const fakeBinName = isWindows ? 'fake-claude-cli.cmd' : 'fake-claude-cli'; + const fakeBin = path.join(tmpDir, fakeBinName); + fs.writeFileSync(fakeBin, isWindows ? '@echo fake\r\n' : '#!/bin/sh\necho fake\n'); + if (!isWindows) fs.chmodSync(fakeBin, 0o755); try { const got = resolveClaudeCommand({ PATH: tmpDir, diff --git a/scripts/test-free-shards.ts b/scripts/test-free-shards.ts index ed1a71c2..6ad9e1da 100755 --- a/scripts/test-free-shards.ts +++ b/scripts/test-free-shards.ts @@ -63,6 +63,11 @@ const WINDOWS_FRAGILE_PATTERNS: Array<{ pattern: RegExp; reason: string }> = [ { pattern: /\.mode\s*&\s*0o[0-7]+/, reason: 'POSIX file mode bitmask (mode & 0o600 etc — Windows fakes mode bits)' }, { pattern: /\.endsWith\(['"]\//, reason: 'hardcoded forward-slash path assertion (Windows uses \\\\)' }, { pattern: /['"]\.\/[a-zA-Z][^"']*['"]\)\s*\.\s*toBe\(true\)/, reason: 'forward-slash path comparison' }, + // Tests that spawn a bash shebang script in bin/ via spawnSync. Git Bash on + // Windows can run `bash /path/to/script` but spawnSync(scriptPath, ...) + // tries to execute the file directly via CreateProcess, which fails on the + // shebang. Catches gstack-question-log.test.ts, gstack-paths.test.ts, etc. + { pattern: /path\.join\([^)]*,\s*['"]bin['"]\s*[,)]/, reason: 'spawns bin/ shebang script (Windows CreateProcess does not parse shebangs)' }, ]; export const DEFAULT_SHARD_COUNT = 20;