Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 14 additions & 22 deletions tests/codex-integration/native-profile-processes.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, expect, test } from "bun:test";
import { existsSync, mkdirSync, mkdtempSync, writeFileSync } from "node:fs";
import { mkdirSync, mkdtempSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { dirname, join } from "node:path";
import {
Expand Down Expand Up @@ -157,27 +157,19 @@ describe("native profile process probe", () => {
});

test("kills and settles a timed-out child", async () => {
const directory = mkdtempSync(join(tmpdir(), "ocx-native-probe-"));
const survived = join(directory, "survived");
const script = [
`setTimeout(() => require('node:fs').writeFileSync(${JSON.stringify(survived)}, 'alive'), 300);`,
"setInterval(() => {}, 1_000);",
].join(" ");
try {
await expect(executeNativeProcess(process.execPath, ["-e", script], {
encoding: "utf8",
timeout: 100,
maxBuffer: 1024,
windowsHide: true,
shell: false,
killSignal: "SIGKILL",
})).rejects.toThrow();
await Bun.sleep(600);
expect(existsSync(survived)).toBe(false);
} finally {
removeTreeWithRetry(directory);
}
});
// A child marker races the parent's timeout when its event loop is busy.
// Check the observed exit signal instead. Normal exit is a finite fuse, so
// disabling the executor timeout fails this assertion without orphaning a child.
const script = "setTimeout(() => process.exit(0), 10_000);";
await expect(executeNativeProcess(process.execPath, ["-e", script], {
encoding: "utf8",
timeout: 100,
maxBuffer: 1024,
windowsHide: true,
shell: false,
killSignal: "SIGKILL",
})).rejects.toMatchObject({ killed: true, signal: "SIGKILL" });
Comment thread
coderabbitai[bot] marked this conversation as resolved.
}, 15_000);

test("rejects output above the configured byte cap", async () => {
await expect(executeNativeProcess(process.execPath, [
Expand Down
Loading