mirror of
https://github.com/garrytan/gstack.git
synced 2026-05-02 03:35:09 +02:00
fix(test): invoke bin/gstack-paths via bash (Windows shebang fix)
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) <noreply@anthropic.com>
This commit is contained in:
@@ -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<string, string | undefined>): Record<string, string> {
|
||||
const result = spawnSync(BIN, [], {
|
||||
const result = spawnSync('bash', [BIN], {
|
||||
env: { PATH: process.env.PATH, ...env } as Record<string, string>,
|
||||
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<string, string>,
|
||||
encoding: 'utf-8',
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user