Skip to content

OpenAI's Codex Security CLI and TypeScript SDK for finding, validating, and fixing security vulnerabilities. npm: https://www.npmjs.com/package/@openai/codex-security

test(ci): preserve native configuration fixture exits (#1794)

Michael D'Angelo5bb8dd8706f7
diff --git a/sdk/typescript/tests-ts/cli-skill-native-config.test.ts b/sdk/typescript/tests-ts/cli-skill-native-config.test.ts
index 90a7e9c79..83b3e0520 100644
--- a/sdk/typescript/tests-ts/cli-skill-native-config.test.ts
+++ b/sdk/typescript/tests-ts/cli-skill-native-config.test.ts
@@ -18,6 +18,46 @@ import {
} from "../src/runtime.js";
import { capture } from "./cli-fixtures.js";
+test.each([0, 23])(
+ "native configuration fixture preserves early exit %s with its input still open",
+ async (exitCode) => {
+ const child = spawn(
+ process.execPath,
+ [
+ fileURLToPath(
+ new URL("./fixtures/skill-native-config.mjs", import.meta.url),
+ ),
+ "-e",
+ `process.stderr.write("synthetic native exit\\n"); process.exitCode = ${exitCode};`,
+ ],
+ {
+ env: { ...process.env, SYNTHETIC_NATIVE_CODEX: process.execPath },
+ stdio: ["pipe", "ignore", "pipe"],
+ windowsHide: true,
+ },
+ );
+ const closed = once(child, "close");
+ let diagnostic = "";
+ child.stderr.on("data", (chunk) => {
+ diagnostic += chunk;
+ });
+ const timeout = setTimeout(() => child.kill(), 10_000);
+ try {
+ const [code, signal] = await closed;
+ expect({ code, signal, diagnostic }).toEqual({
+ code: exitCode,
+ signal: null,
+ diagnostic: "synthetic native exit\n",
+ });
+ } finally {
+ clearTimeout(timeout);
+ child.stdin.destroy();
+ child.stderr.destroy();
+ child.kill();
+ }
+ },
+);
+
test.each([
["trusted", undefined, "patch", ""],
["untrusted", undefined, "patch", ""],
diff --git a/sdk/typescript/tests-ts/fixtures/skill-native-config.mjs b/sdk/typescript/tests-ts/fixtures/skill-native-config.mjs
index 9b2c525bf..39b478635 100644
--- a/sdk/typescript/tests-ts/fixtures/skill-native-config.mjs
+++ b/sdk/typescript/tests-ts/fixtures/skill-native-config.mjs
@@ -9,13 +9,19 @@ const child = spawn(process.env.SYNTHETIC_NATIVE_CODEX, process.argv.slice(2), {
windowsHide: true,
});
child.stderr.pipe(process.stderr);
+const input = createInterface({ input: process.stdin });
+child.once("close", (code) => {
+ process.exitCode = code ?? 1;
+ input.close();
+ process.stdin.destroy();
+});
let turnRequest;
let modelProvider;
let initialConfig;
let daybreakEnabled;
await Promise.all([
(async () => {
- for await (const line of createInterface({ input: process.stdin })) {
+ for await (const line of input) {
const request = JSON.parse(line);
if (request.id !== undefined) methods.set(request.id, request.method);
if (request.method === "thread/start") {