



























@@ -106,7 +106,7 @@ describe("qa suite runtime agent process helpers", () => {
106106107107await waitForSpawnCount(1);
108108child.stdout.emit("data", Buffer.from("ok\n"));
109-child.emit("exit", 0);
109+child.emit("close", 0);
110110111111await expect(pending).resolves.toBe("ok");
112112const spawnCall = firstSpawnCall();
@@ -142,7 +142,7 @@ describe("qa suite runtime agent process helpers", () => {
142142await waitForSpawnCount(1);
143143expect(timeoutSpy).toHaveBeenCalledWith(expect.any(Function), MAX_TIMER_TIMEOUT_MS);
144144child.stdout.emit("data", Buffer.from("ok\n"));
145-child.emit("exit", 0);
145+child.emit("close", 0);
146146await expect(pending).resolves.toBe("ok");
147147} finally {
148148timeoutSpy.mockRestore();
@@ -208,7 +208,7 @@ describe("qa suite runtime agent process helpers", () => {
208208209209await waitForSpawnCount(1);
210210child.stdout.emit("data", Buffer.from("ok\n"));
211-child.emit("exit", 0);
211+child.emit("close", 0);
212212213213await expect(pending).resolves.toBe("ok");
214214const spawnCall = firstSpawnCall();
@@ -246,7 +246,7 @@ describe("qa suite runtime agent process helpers", () => {
246246247247await waitForSpawnCount(1);
248248child.stdout.emit("data", Buffer.from('{"ok":true}\n'));
249-child.emit("exit", 0);
249+child.emit("close", 0);
250250251251await expect(pending).resolves.toEqual({ ok: true });
252252});
@@ -277,7 +277,7 @@ describe("qa suite runtime agent process helpers", () => {
277277'\u001b[35m[plugins]\u001b[39m \u001b[36mcodex loaded plugin package metadata\u001b[39m\n{"results":[{"text":"ORBIT-10"}]}\n',
278278),
279279);
280-child.emit("exit", 0);
280+child.emit("close", 0);
281281282282await expect(pending).resolves.toEqual({ results: [{ text: "ORBIT-10" }] });
283283});
@@ -308,11 +308,38 @@ describe("qa suite runtime agent process helpers", () => {
308308'[plugins] memory-core loaded plugin package metadata\n{\n "results": [\n {\n "text": "ORBIT-10"\n }\n ]\n}\n',
309309),
310310);
311-child.emit("exit", 0);
311+child.emit("close", 0);
312312313313await expect(pending).resolves.toEqual({ results: [{ text: "ORBIT-10" }] });
314314});
315315316+it("waits for stdio close before parsing qa cli stdout", async () => {
317+const child = createSpawnedProcess();
318+spawnMock.mockReturnValue(child);
319+320+const pending = runQaCli(
321+{
322+repoRoot: "/repo",
323+gateway: {
324+tempRoot: "/tmp/runtime",
325+runtimeEnv: {},
326+},
327+primaryModel: "openai/gpt-5.5",
328+alternateModel: "openai/gpt-5.5-mini",
329+providerMode: "mock-openai",
330+} as never,
331+["memory", "search", "--json"],
332+{ json: true },
333+);
334+335+await waitForSpawnCount(1);
336+child.emit("exit", 0);
337+child.stdout.emit("data", Buffer.from('{"results":[{"text":"LATE-STDOUT"}]}\n'));
338+child.emit("close", 0);
339+340+await expect(pending).resolves.toEqual({ results: [{ text: "LATE-STDOUT" }] });
341+});
342+316343it("rejects oversized qa cli stdout instead of parsing truncated output", async () => {
317344const child = createSpawnedProcess();
318345spawnMock.mockReturnValue(child);
@@ -334,7 +361,7 @@ describe("qa suite runtime agent process helpers", () => {
334361335362await waitForSpawnCount(1);
336363child.stdout.emit("data", Buffer.alloc(QA_CHILD_STDOUT_MAX_BYTES + 1, "x"));
337-child.emit("exit", 0);
364+child.emit("close", 0);
338365339366await expect(pending).rejects.toThrow(
340367`qa cli stdout exceeded ${QA_CHILD_STDOUT_MAX_BYTES} bytes; refusing to parse truncated output`,
@@ -365,7 +392,7 @@ describe("qa suite runtime agent process helpers", () => {
365392"data",
366393Buffer.from(`head-marker\n${"x".repeat(QA_CHILD_STDERR_TAIL_BYTES)}\ntail-marker`),
367394);
368-child.emit("exit", 1);
395+child.emit("close", 1);
369396370397const error = await pending.catch((value: unknown) => value);
371398expect(error).toBeInstanceOf(Error);
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。