Understand any codebase instantly. System intelligence for codebases, built for humans and AI.
TypeScript aiai-memoryclaude-codeclicode-analysiscode-mappingcode-memorycodebase-understandingcodexdeveloper-toolsllmopenclawpersistent-memoryprogram-analysissoftware-architecturesystem-intelligencesystem-mapping
test(cli): restore a pre-existing IX_HOME after each resolver test (QA-06B)
KageBinaryd70fc7982c01
diff --git a/ix-cli/src/cli/__tests__/file-resolution.test.ts b/ix-cli/src/cli/__tests__/file-resolution.test.tsindex 801070fc..960d539a 100644--- a/ix-cli/src/cli/__tests__/file-resolution.test.ts+++ b/ix-cli/src/cli/__tests__/file-resolution.test.ts@@ -1,6 +1,6 @@// Copyright 2026 Ix Infrastructure Inc.-import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";+import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";import { Command } from "commander";import * as fs from "node:fs";import * as os from "node:os";@@ -99,11 +99,13 @@ const FILE_A = node("file-a-id", "a.ts", "file", "src/a.ts");let dir: string;let savedCwd: string;let savedExitCode: typeof process.exitCode;+let savedIxHome: string | undefined;beforeEach(() => {// A non-git directory of its own: nothing here touches the real checkout or// ~/.ix, and git has no repository to answer from.dir = fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(), "ix-file-res-")));+ savedIxHome = process.env.IX_HOME;process.env.IX_HOME = path.join(dir, ".ix");savedCwd = process.cwd();process.chdir(dir);@@ -124,7 +126,8 @@ beforeEach(() => {afterEach(() => {process.exitCode = savedExitCode;process.chdir(savedCwd);- delete process.env.IX_HOME;+ if (savedIxHome === undefined) delete process.env.IX_HOME;+ else process.env.IX_HOME = savedIxHome;resetReadScope();fs.rmSync(dir, { recursive: true, force: true });vi.restoreAllMocks();@@ -291,3 +294,19 @@ describe("ambiguous result structure", () => {expect(result.result.diagnostics?.[0].code).toBe("ambiguous_resolution");});});++describe("test isolation", () => {+ // afterEach must put back an IX_HOME the worker already had, not delete it.+ const ambient = path.join(os.tmpdir(), "ix-file-res-ambient-ix-home");+ beforeAll(() => {+ process.env.IX_HOME = ambient;+ });+ afterAll(() => {+ const after = process.env.IX_HOME;+ delete process.env.IX_HOME;+ expect(after).toBe(ambient);+ });+ it("points IX_HOME at the per-test temp dir while a test runs", () => {+ expect(process.env.IX_HOME).toBe(path.join(dir, ".ix"));+ });+});diff --git a/ix-cli/src/cli/__tests__/resolver-consistency.test.ts b/ix-cli/src/cli/__tests__/resolver-consistency.test.tsindex 14f0edd6..e9e1c254 100644--- a/ix-cli/src/cli/__tests__/resolver-consistency.test.ts+++ b/ix-cli/src/cli/__tests__/resolver-consistency.test.ts@@ -1,6 +1,6 @@// Copyright 2026 Ix Infrastructure Inc.-import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";+import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";import { Command, CommanderError } from "commander";import * as fs from "node:fs";import * as os from "node:os";@@ -126,10 +126,12 @@ async function run(register: Register, args: string[]): Promise<void> {let dir: string;let savedCwd: string;let savedExitCode: typeof process.exitCode;+let savedIxHome: string | undefined;beforeEach(() => {// read looks on disk after resolving; keep it off the real checkout and ~/.ix.dir = fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(), "ix-resolver-")));+ savedIxHome = process.env.IX_HOME;process.env.IX_HOME = path.join(dir, ".ix");savedCwd = process.cwd();process.chdir(dir);@@ -147,7 +149,8 @@ beforeEach(() => {afterEach(() => {process.exitCode = savedExitCode;process.chdir(savedCwd);- delete process.env.IX_HOME;+ if (savedIxHome === undefined) delete process.env.IX_HOME;+ else process.env.IX_HOME = savedIxHome;resetReadScope();fs.rmSync(dir, { recursive: true, force: true });vi.restoreAllMocks();@@ -177,3 +180,19 @@ describe("resolver flag consistency across content commands", () => {});});});++describe("test isolation", () => {+ // afterEach must put back an IX_HOME the worker already had, not delete it.+ const ambient = path.join(os.tmpdir(), "ix-resolver-ambient-ix-home");+ beforeAll(() => {+ process.env.IX_HOME = ambient;+ });+ afterAll(() => {+ const after = process.env.IX_HOME;+ delete process.env.IX_HOME;+ expect(after).toBe(ambient);+ });+ it("points IX_HOME at the per-test temp dir while a test runs", () => {+ expect(process.env.IX_HOME).toBe(path.join(dir, ".ix"));+ });+});