Skip to content

Commit 2dfb483

Browse files
anandgupta42claude
andcommitted
test: isolate warehouse_list hint tests from the shared global connections file
`Registry.add()` in `telemetry-safety.test.ts` and `adversarial.test.ts` persists `test_add` and `evil` to the test-home global `connections.json`. When CI ran those files first in the same process, the empty-registry cases in `warehouse-list-hint.test.ts` listed them and failed. The hint tests now set that file aside in `beforeEach` and restore it in `afterEach`. Verified by seeding a global file before the suite: 5 failures before, 9/9 pass after. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent e507249 commit 2dfb483

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

‎packages/opencode/test/altimate/warehouse-list-hint.test.ts‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,13 @@ function toolCtx() {
2424
let project: string
2525
let prevCwd: string
2626
let ambientConnEnv: Record<string, string>
27+
let ambientGlobalConfig: string | undefined
2728

2829
beforeEach(() => {
30+
// Registry.add() in other files persists to the shared test-home global file; set it aside for the empty-registry cases.
31+
const globalFile = Registry.globalConfigPath()
32+
ambientGlobalConfig = fs.existsSync(globalFile) ? fs.readFileSync(globalFile, "utf-8") : undefined
33+
fs.rmSync(globalFile, { force: true })
2934
// Ambient connection env vars would make the empty-registry assertions depend on the caller's shell.
3035
ambientConnEnv = {}
3136
for (const [key, value] of Object.entries(process.env)) {
@@ -45,6 +50,12 @@ afterEach(() => {
4550
Registry.reset()
4651
fs.rmSync(project, { recursive: true, force: true })
4752
Object.assign(process.env, ambientConnEnv)
53+
const globalFile = Registry.globalConfigPath()
54+
if (ambientGlobalConfig === undefined) fs.rmSync(globalFile, { force: true })
55+
else {
56+
fs.mkdirSync(path.dirname(globalFile), { recursive: true })
57+
fs.writeFileSync(globalFile, ambientGlobalConfig)
58+
}
4859
})
4960

5061
describe("warehouse_list no-connections hint", () => {

0 commit comments

Comments
 (0)