Skip to content

Commit 0c461c6

Browse files
committed
test: make Windows root fixtures deterministic
1 parent b2660d3 commit 0c461c6

2 files changed

Lines changed: 15 additions & 8 deletions

File tree

‎tests/cursor-native-exec.test.ts‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,10 @@ describe("Cursor native exec bridge", () => {
287287
const dir = mkdtempSync(join(tmpdir(), "ocx-cursor-shell-"));
288288
const shell = decode((await handleCursorNativeExec(execMessage({
289289
case: "shellArgs",
290-
value: create(ShellArgsSchema, { command: "printf cursor-ok", workingDirectory: dir }),
290+
value: create(ShellArgsSchema, {
291+
command: "node -e \"process.stdout.write('cursor-ok')\"",
292+
workingDirectory: dir,
293+
}),
291294
}), { unsafeAllowNativeLocalExec: true }))[0]);
292295

293296
expect(shell.message.case).toBe("shellResult");
@@ -301,7 +304,10 @@ describe("Cursor native exec bridge", () => {
301304
const dir = mkdtempSync(join(tmpdir(), "ocx-cursor-stream-"));
302305
const replies = await handleCursorNativeExec(execMessage({
303306
case: "shellStreamArgs",
304-
value: create(ShellArgsSchema, { command: "printf stream-ok", workingDirectory: dir }),
307+
value: create(ShellArgsSchema, {
308+
command: "node -e \"process.stdout.write('stream-ok')\"",
309+
workingDirectory: dir,
310+
}),
305311
}), { unsafeAllowNativeLocalExec: true });
306312
const decodedAll = replies.map(reply => fromBinary(AgentClientMessageSchema, reply));
307313
const execFrames = decodedAll

‎tests/settings-stream-mode.test.ts‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@
77
* settable alone via PUT (legacy codexAutoStart-only PUTs keep working).
88
*/
99
import { afterEach, beforeEach, describe, expect, test } from "bun:test";
10-
import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
10+
import { existsSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
11+
import { tmpdir } from "node:os";
1112
import { join } from "node:path";
1213
import { getConfigPath, loadConfig, saveConfig } from "../src/config";
1314
import { handleManagementAPI } from "../src/server/management-api";
1415
import type { OcxConfig } from "../src/types";
1516

16-
const TEST_DIR = join(import.meta.dir, ".tmp-settings-stream-mode-test");
1717
const previousHome = process.env.OPENCODEX_HOME;
18+
let testDir = "";
1819

1920
function baseConfig(): OcxConfig {
2021
return {
@@ -46,15 +47,15 @@ function getSettings(config: OcxConfig): Promise<Response | null> {
4647
}
4748

4849
beforeEach(() => {
49-
if (existsSync(TEST_DIR)) rmSync(TEST_DIR, { recursive: true });
50-
mkdirSync(TEST_DIR, { recursive: true });
51-
process.env.OPENCODEX_HOME = TEST_DIR;
50+
testDir = mkdtempSync(join(tmpdir(), "ocx-settings-stream-mode-"));
51+
process.env.OPENCODEX_HOME = testDir;
5252
});
5353

5454
afterEach(() => {
5555
if (previousHome === undefined) delete process.env.OPENCODEX_HOME;
5656
else process.env.OPENCODEX_HOME = previousHome;
57-
if (existsSync(TEST_DIR)) rmSync(TEST_DIR, { recursive: true });
57+
if (testDir && existsSync(testDir)) rmSync(testDir, { recursive: true, force: true });
58+
testDir = "";
5859
});
5960

6061
describe("GET /api/settings", () => {

0 commit comments

Comments
 (0)