mirror of
https://github.com/garrytan/gstack.git
synced 2026-11-09 18:28:15 +01:00
test(preload): strip the Capy launch markers so a direct bun test matches the shard sandbox
Red Team finding: the launch-marker scrub lived only in createShardSandbox, so a direct `bun test <file>` run under an unattended Capy session inherited GSTACK_SESSION_KIND, GSTACK_CAPY, GSTACK_EPHEMERAL and GSTACK_INSTALL_VERDICT (GSTA-99's symptom). The preload now deletes the same four names, and test/shard-engine.test.ts imports CAPY_LAUNCH_MARKERS instead of re-typing them. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
This commit is contained in:
1 parent
9e5ccbb6eb
commit
e32274caf4
2 files changed
+7
-1
No files matched your search
@@ -33,6 +33,11 @@ for (const name of ['GSTACK_STATE_ROOT', 'GSTACK_STATE_DIR']) {
|
||||
delete process.env[name];
|
||||
process.stderr.write(`test-setup: stripped inherited ${name}; tests isolate state via GSTACK_HOME\n`);
|
||||
}
|
||||
// The Capy installer's launch markers (GSTA-99, GSTA-104): a focused `bun test`
|
||||
// run from a shell that sourced the launch file would hand every product child
|
||||
// an unattended Capy session it never set up. The shard engine strips the same
|
||||
// list for the lanes; this reaches direct runs too.
|
||||
for (const name of ['GSTACK_SESSION_KIND', 'GSTACK_CAPY', 'GSTACK_EPHEMERAL', 'GSTACK_INSTALL_VERDICT']) delete process.env[name];
|
||||
process.env.GSTACK_TEST_LEGACY_ROOT = path.join(os.tmpdir(), `gstack-test-legacy-root-${process.pid}-${Date.now()}-unused`);
|
||||
// Workflow leases (bin/gstack-lease) default to the installation's git dir;
|
||||
// for the dev checkout under test that is this repo's .git, and a live test
|
||||
|
||||
@@ -24,6 +24,7 @@ import {
|
||||
strictShardStatus,
|
||||
writeDurationSeed,
|
||||
zeroExecutionVerdict,
|
||||
CAPY_LAUNCH_MARKERS,
|
||||
} from '../scripts/lib/shard-engine';
|
||||
import { FREE_LANE_POLICY, exitCodeFor, runFreeShard } from '../scripts/test-free-shards';
|
||||
import {
|
||||
@@ -252,7 +253,7 @@ describe('shard engine: capture and isolation', () => {
|
||||
for (const box of [a, b]) {
|
||||
expect(box.env.KEEP).toBe('1');
|
||||
expect(box.env.GSTACK_HOME).toBeUndefined();
|
||||
for (const key of ['GSTACK_SESSION_KIND', 'GSTACK_CAPY', 'GSTACK_EPHEMERAL', 'GSTACK_INSTALL_VERDICT']) expect(box.env[key]).toBeUndefined();
|
||||
for (const key of CAPY_LAUNCH_MARKERS) expect(box.env[key]).toBeUndefined();
|
||||
expect(box.env.GSTACK_STATE_ROOT).toBe('/kept-root');
|
||||
for (const key of ['TMPDIR', 'TEMP', 'TMP']) expect(box.env[key]).toBe(box.tmp);
|
||||
expect(box.env.CHROMIUM_PROFILE).toBe(path.join(box.stateDir, 'chromium-profile'));
|
||||
|
||||
Reference in new issue
Block a user