Skip to content

Commit bfb372e

Browse files
author
pavelhov
committed
test: protect macOS first-run temp cleanup
1 parent d699683 commit bfb372e

1 file changed

Lines changed: 26 additions & 26 deletions

File tree

‎tests/macos-first-run.test.ts‎

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -29,33 +29,33 @@ function runProductionScenario(options: {
2929
codexHomeFileRaw?: string;
3030
}): ProductionSnapshot {
3131
const root = mkdtempSync(join(tmpdir(), "ccx-macos-first-run-"));
32-
const appHome = join(root, "app-home");
33-
const codexHome = join(root, "codex-home");
34-
mkdirSync(appHome);
35-
mkdirSync(codexHome);
36-
if (options.appRaw !== undefined) writeFileSync(join(appHome, "config.json"), options.appRaw, "utf8");
37-
if (options.codexRaw !== undefined) writeFileSync(join(codexHome, "config.toml"), options.codexRaw, "utf8");
38-
39-
const script = `
40-
globalThis.fetch = () => { throw new Error("network blocked by macOS first-run test"); };
41-
const { rmSync, writeFileSync } = await import("node:fs");
42-
const { getDefaultConfig, validateConfigCandidate } = await import("./src/config.ts");
43-
const { prepareMacOSAppStart } = await import("./src/cli/macos-first-run.ts");
44-
const codexHome = process.env.CODEX_HOME;
45-
if (process.env.CCX_TEST_REPLACE_CODEX_HOME === "1") {
46-
rmSync(codexHome, { recursive: true, force: true });
47-
writeFileSync(codexHome, process.env.CCX_TEST_CODEX_SENTINEL ?? "", "utf8");
48-
}
49-
console.log(JSON.stringify({
50-
result: prepareMacOSAppStart(),
51-
expectedDefault: validateConfigCandidate(getDefaultConfig()).config,
52-
expectedMissing: validateConfigCandidate({
53-
...getDefaultConfig(),
54-
clientIntegrations: { codex: false },
55-
}).config,
56-
}));
57-
`;
5832
try {
33+
const appHome = join(root, "app-home");
34+
const codexHome = join(root, "codex-home");
35+
mkdirSync(appHome);
36+
mkdirSync(codexHome);
37+
if (options.appRaw !== undefined) writeFileSync(join(appHome, "config.json"), options.appRaw, "utf8");
38+
if (options.codexRaw !== undefined) writeFileSync(join(codexHome, "config.toml"), options.codexRaw, "utf8");
39+
40+
const script = `
41+
globalThis.fetch = () => { throw new Error("network blocked by macOS first-run test"); };
42+
const { rmSync, writeFileSync } = await import("node:fs");
43+
const { getDefaultConfig, validateConfigCandidate } = await import("./src/config.ts");
44+
const { prepareMacOSAppStart } = await import("./src/cli/macos-first-run.ts");
45+
const codexHome = process.env.CODEX_HOME;
46+
if (process.env.CCX_TEST_REPLACE_CODEX_HOME === "1") {
47+
rmSync(codexHome, { recursive: true, force: true });
48+
writeFileSync(codexHome, process.env.CCX_TEST_CODEX_SENTINEL ?? "", "utf8");
49+
}
50+
console.log(JSON.stringify({
51+
result: prepareMacOSAppStart(),
52+
expectedDefault: validateConfigCandidate(getDefaultConfig()).config,
53+
expectedMissing: validateConfigCandidate({
54+
...getDefaultConfig(),
55+
clientIntegrations: { codex: false },
56+
}).config,
57+
}));
58+
`;
5959
const childEnv = {
6060
...process.env,
6161
CODEXCOMMANDER_HOME: appHome,

0 commit comments

Comments
 (0)