diff --git a/browse/test/cdp-e2e.test.ts b/browse/test/cdp-e2e.test.ts index c6b2c8a8a..c2d731350 100644 --- a/browse/test/cdp-e2e.test.ts +++ b/browse/test/cdp-e2e.test.ts @@ -18,6 +18,12 @@ import { startTestServer } from './test-server'; import { BrowserManager } from '../src/browser-manager'; const TMP_HOME = path.join(os.tmpdir(), `gstack-cdp-e2e-${process.pid}-${Date.now()}`); +// Shard runs execute many test files in ONE bun process: a module-scope env +// mutation without restore leaks into every LATER file in the shard. This +// exact leak once pointed a sibling test's GSTACK_HOME at our temp dir, +// which then got baked into artifacts that outlived it (dangling symlinks +// into a deleted render dir). Save + restore in afterAll. +const ORIGINAL_GSTACK_HOME = process.env.GSTACK_HOME; process.env.GSTACK_HOME = TMP_HOME; process.env.GSTACK_TELEMETRY_OFF = '1'; // don't pollute analytics during tests @@ -36,6 +42,8 @@ beforeAll(async () => { }); afterAll(async () => { + if (ORIGINAL_GSTACK_HOME === undefined) delete process.env.GSTACK_HOME; + else process.env.GSTACK_HOME = ORIGINAL_GSTACK_HOME; try { await bm.cleanup?.(); } catch {} try { testServer.server.stop(); } catch {} await fs.rm(TMP_HOME, { recursive: true, force: true }); diff --git a/test/branch-slug-hygiene.test.ts b/test/branch-slug-hygiene.test.ts index 2b51460c0..58c7cccaf 100644 --- a/test/branch-slug-hygiene.test.ts +++ b/test/branch-slug-hygiene.test.ts @@ -36,7 +36,7 @@ const FILENAME_PREFIX = /\$\{?_BRANCH\}?[A-Za-z0-9._-]*\.(?:jsonl|json|md|txt|lo function renderedSkillFiles(): string[] { const out = execSync( - `find "${ROOT}" -name 'SKILL.md' -not -path '*/node_modules/*' ; find "${ROOT}" -path '*/sections/*.md' -not -path '*/node_modules/*'`, + `find "${ROOT}" -name 'SKILL.md' -not -path '*/node_modules/*' -not -path '*/.claude/*' ; find "${ROOT}" -path '*/sections/*.md' -not -path '*/node_modules/*' -not -path '*/.claude/*'`, { encoding: 'utf-8' }, ); return out.split('\n').filter(Boolean); diff --git a/test/codex-web-search-flag.test.ts b/test/codex-web-search-flag.test.ts index ad4ec3dc6..7e13ea607 100644 --- a/test/codex-web-search-flag.test.ts +++ b/test/codex-web-search-flag.test.ts @@ -29,6 +29,9 @@ function grepRepo(pattern: string, includes: string[]): string[] { .split('\n') .filter(Boolean) .filter((f) => !f.includes('node_modules')) + // The workspace-local .claude/ install is not generated output and can + // carry dangling symlinks from unrelated sessions. + .filter((f) => !f.includes('/.claude/')) .filter((f) => !f.endsWith('test/codex-web-search-flag.test.ts')); } diff --git a/test/empty-find-fallthrough.test.ts b/test/empty-find-fallthrough.test.ts index 363ba4743..10782ae9d 100644 --- a/test/empty-find-fallthrough.test.ts +++ b/test/empty-find-fallthrough.test.ts @@ -86,7 +86,10 @@ describe('empty find must not fall through to cwd (#2483)', () => { const hits = out .split('\n') .filter(Boolean) - .filter((f) => !f.includes('node_modules')); + .filter((f) => !f.includes('node_modules')) + // The workspace-local .claude/ install is not generated output and can + // carry dangling symlinks from unrelated sessions. + .filter((f) => !f.includes('/.claude/')); expect(hits).toEqual([]); }); });