extractCurrentMilestone reads STATE.md via planningDir(cwd), which is workstream-aware (honours GSD_PROJECT/GSD_WORKSTREAM). The fixtures write STATE.md to the plain <tmp>/.planning/STATE.md, so a developer shell inside a GSD workstream (GSD_WORKSTREAM exported) redirected the read to a non-existent workstream subdir -> version=null -> closed milestone sections leaked into the slice and assertions failed. Clean CI/Docker env never hit it. Not a Node-26 regex bug; reproduces identically on any Node with GSD_WORKSTREAM set. - scripts/run-tests.cjs: strip GSD_PROJECT/GSD_WORKSTREAM before spawning test children so the local runner env matches clean CI/Docker. - tests/roadmap-phase-fallback.test.cjs: file-level beforeEach/afterEach save/delete/restore of both vars; new regression test pinning workstream-aware STATE.md resolution. - tests/run-tests-harness.test.cjs: guard asserting the runner strips both vars (so removing the deletion fails clean CI). Closes #872 Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -260,6 +260,32 @@ test('boom', () => { throw new Error('intentional'); });
|
||||
});
|
||||
});
|
||||
|
||||
describe('env hermeticity', () => {
|
||||
// Regression guard for the two `delete process.env.GSD_PROJECT/GSD_WORKSTREAM`
|
||||
// lines added in scripts/run-tests.cjs main() right after ensureBuiltArtifacts().
|
||||
// If those deletions are removed, the fixture's assertions fail inside the child
|
||||
// node:test process → non-zero harness exit → this test fails → CI catches it.
|
||||
test('harness strips GSD_PROJECT and GSD_WORKSTREAM before running child tests', () => {
|
||||
// Write a fixture that asserts both vars are absent in the child process env.
|
||||
const FIXTURE = `'use strict';
|
||||
const { test } = require('node:test');
|
||||
const assert = require('node:assert/strict');
|
||||
test('ambient GSD workstream vars are stripped by the runner', () => {
|
||||
assert.strictEqual(process.env.GSD_PROJECT, undefined);
|
||||
assert.strictEqual(process.env.GSD_WORKSTREAM, undefined);
|
||||
});
|
||||
`;
|
||||
fs.writeFileSync(path.join(tmpDir, 'env-hermeticity.test.cjs'), FIXTURE, 'utf8');
|
||||
// Pass both vars in the ambient env given to the harness process.
|
||||
// The harness must delete them before spawning the child node:test process.
|
||||
const r = runHarness(tmpDir, [], {
|
||||
GSD_PROJECT: 'ambient-proj',
|
||||
GSD_WORKSTREAM: 'ambient-ws',
|
||||
});
|
||||
assert.strictEqual(r.status, 0, r.stderr);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Windows argv-overflow chunking (issue #3597)', () => {
|
||||
// Windows CreateProcess caps lpCommandLine at 32,767 chars. With ~550
|
||||
// tests the unchunked spawn fails instantly on Windows with no test
|
||||
|
||||
Reference in New Issue
Block a user