fix(windows-ci): platform-aware claude-bin test + curate bin/ shebang spawns

Round 3 of windows-free-tests fixes. Round 2 (LF gitattributes + server-node.mjs
build) cleared shard 1 entirely (skill-collision-sentinel and tab-isolation
green). Shard 2 surfaced two more issues:

1. browse/test/claude-bin.test.ts:50 — the "PATH-resolvable override" test
   creates a fake binary 'fake-claude-cli' (no extension) and expects
   Bun.which to find it. On Windows, Bun.which probes PATHEXT extensions
   (.cmd, .exe, .bat) — a bare-name file is not discoverable. Production
   behavior is correct; the test was Mac/Linux-shaped.

   Fix: branch on process.platform. On Windows, write 'fake-claude-cli.cmd'
   with a Windows batch payload instead of a POSIX shebang script.

2. test/gstack-question-log.test.ts (and 18 sibling tests) — spawn a bash
   shebang script via spawnSync(BIN, args). Git Bash on Windows can run
   `bash /path/to/script` but spawnSync invokes CreateProcess directly,
   which doesn't parse #!/usr/bin/env bash. All these tests are
   Windows-fragile and can't run as-is.

   Fix: extend WINDOWS_FRAGILE_PATTERNS with `path.join(.., 'bin', ..)`
   detector. Curates 19 additional tests (benchmark-cli, brain-sync,
   builder-profile, explain-level-config, gbrain-*, gstack-question-*,
   hook-scripts, learnings, plan-tune, review-log, secret-sink-harness,
   taste-engine, telemetry, timeline, uninstall).

Curated Windows subset: 95 → 76 tests (~59% of free suite). Still
meaningful Windows coverage. The 52 excluded tests are tracked as a
follow-up TODO for full Windows parity (shebang-bin spawns + POSIX file
modes + raw /tmp/ etc).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Garry Tan
2026-04-27 23:57:13 -07:00
parent bfa579515c
commit 900a619f31
2 changed files with 12 additions and 3 deletions
+5
View File
@@ -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;