fix(#372): harden bug-3668 resolver test for Windows/CI (non-login shell + CRLF) (#374)

* fix(#372): use non-login shell in bug-3668 resolver test for hermetic PATH

bash -lc re-sourced profile files (e.g. Homebrew shellenv) that prepended
real bin dirs ahead of the test's injected PATH, so the installed-gsd-tools
fallback subtest resolved a host-global gsd-tools instead of the injected
fake — failing on dev machines and CI-adjacent benches while passing on
clean CI. Use bash -c (non-login) so the injected PATH is authoritative.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* fix(#372): split workflow snippet on CRLF in bug-3668 resolver test

extractResolverSnippet split on '\n' and exact-matched the closing \`fi\`
line, so on a Windows checkout (CRLF) the line was \`fi\r\`, the end marker
was never found, and the test failed with "SDK resolution snippet must end
with fi". Split on /\r?\n/ so extraction works on LF and CRLF checkouts and
the snippet handed to bash is carriage-return-free.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* fix(#372): assert resolver bin by normalized suffix, not exact OS path

On Windows the snippet runs under Git bash, so GSD_TOOLS is reported POSIX-
style / mixed-separator while the test built its expected regex from Node
path.join (backslashes) — the resolver was correct (installed:/runtime: output
proves the right bin ran) but the exact-path assertions failed. Normalize
separators and assert the GSD_TOOLS path suffix, keeping the behavioral
installed:/runtime: assertions as the primary checks.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Tom Boucher
2026-05-26 22:33:49 -04:00
committed by GitHub
parent 9dd2c87c6c
commit 4fbb61c915

View File

@@ -18,7 +18,7 @@ const WORKFLOW_PATH = path.join(__dirname, '..', 'get-shit-done', 'workflows', '
function extractResolverSnippet() {
const content = fs.readFileSync(WORKFLOW_PATH, 'utf8');
const lines = content.split('\n');
const lines = content.split(/\r?\n/);
const start = lines.findIndex((line) => line.includes('SDK resolution: prefer local gsd-tools.cjs'));
assert.notEqual(start, -1, 'next.md must contain the SDK resolution snippet');
@@ -39,7 +39,7 @@ function runResolver({ cwd, runtimeDir, pathDir }) {
'$GSD_SDK query state.json',
].join('\n');
return execFileSync('bash', ['-lc', script], {
return execFileSync('bash', ['-c', script], {
cwd,
env: {
...process.env,
@@ -65,7 +65,10 @@ describe('bug-3668: workflow SDK resolver supports installed user projects', ()
const output = runResolver({ cwd: project, pathDir: bin });
assert.match(output, new RegExp(`GSD_TOOLS=${path.join(bin, 'gsd-tools').replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}`));
// Normalize separators so the assertion works on Windows (Git bash emits POSIX paths)
const norm = output.replace(/\\/g, '/');
// subtest 1: the resolved bin is the PATH-fallback gsd-tools (suffix /bin/gsd-tools, no .cjs)
assert.match(norm, /GSD_TOOLS=\S*\/bin\/gsd-tools(?:\s|$)/m);
assert.match(output, /installed:query state\.json/);
});
@@ -83,7 +86,10 @@ describe('bug-3668: workflow SDK resolver supports installed user projects', ()
const output = runResolver({ cwd: project, runtimeDir: runtime, pathDir: pathBin });
assert.match(output, new RegExp(`GSD_TOOLS=${path.join(runtime, 'get-shit-done', 'bin', 'gsd-tools.cjs').replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}`));
// Normalize separators so the assertion works on Windows (Git bash emits POSIX paths)
const norm = output.replace(/\\/g, '/');
// subtest 2: the resolved bin is the RUNTIME_DIR local runtime (suffix /get-shit-done/bin/gsd-tools.cjs)
assert.match(norm, /GSD_TOOLS=\S*\/get-shit-done\/bin\/gsd-tools\.cjs(?:\s|$)/m);
assert.match(output, /runtime:query state\.json/);
assert.doesNotMatch(output, /installed:query state\.json/);
});