From 05b1740a40509394a017743d47f33a485a39a42d Mon Sep 17 00:00:00 2001 From: Garry Tan Date: Tue, 28 Apr 2026 00:28:44 -0700 Subject: [PATCH] fix(test): invoke bin/gstack-paths via bash (Windows shebang fix) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Round 13 of windows-free-tests fixes. Round 12 (scope pivot) revealed all 8 gstack-paths tests fail on Windows because the test invokes the bash shebang script directly: spawnSync(BIN, []) # BIN = path.join(ROOT, 'bin', 'gstack-paths') Windows CreateProcess can't parse `#!/usr/bin/env bash` from the file. The script never runs on Windows via this invocation path. Fix: change to `spawnSync('bash', [BIN], ...)`. This matches production usage — the script is sourced from inside skill bash blocks via `eval "$(~/.claude/skills/gstack/bin/gstack-paths)"`, where bash is always the executor. Mac/Linux behavior is identical (bash invocation of a bash script). Verified locally: 8/8 tests still pass on macOS. Co-Authored-By: Claude Opus 4.7 (1M context) --- test/gstack-paths.test.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/test/gstack-paths.test.ts b/test/gstack-paths.test.ts index 030d2374..987897e0 100644 --- a/test/gstack-paths.test.ts +++ b/test/gstack-paths.test.ts @@ -5,8 +5,13 @@ import * as path from 'path'; const ROOT = path.resolve(import.meta.dir, '..'); const BIN = path.join(ROOT, 'bin', 'gstack-paths'); +// Invoke via `bash` rather than executing the shebang-script directly. +// On Windows, spawnSync(scriptPath, ...) goes through CreateProcess, which +// doesn't parse `#!/usr/bin/env bash`. Production usage always sources the +// helper from inside a bash block (`eval "$(~/.claude/skills/gstack/bin/gstack-paths)"`) +// so bash is always the executor — this matches that contract. function run(env: Record): Record { - const result = spawnSync(BIN, [], { + const result = spawnSync('bash', [BIN], { env: { PATH: process.env.PATH, ...env } as Record, encoding: 'utf-8', }); @@ -70,7 +75,7 @@ describe('gstack-paths', () => { }); test('output is shell-evalable: only KEY=VALUE lines, no extra prose', () => { - const result = spawnSync(BIN, [], { + const result = spawnSync('bash', [BIN], { env: { PATH: process.env.PATH, HOME: '/tmp/h' } as Record, encoding: 'utf-8', });