From 0f4bc645dab2f4f03c45e59e0feaf36f64767a7c Mon Sep 17 00:00:00 2001 From: Tianyi Cui <53024+tianyicui@users.noreply.github.com> Date: Sun, 19 Jul 2026 12:42:59 +0800 Subject: [PATCH] test(acp-snapshot): inherit descendant stdio portably Pass the fake descendant the parent process's stdout and stderr stream handles instead of Unix-style numeric file descriptors. This lets Windows duplicate the live ACP and diagnostic pipes so launcher shutdown can prove that inherited handles, buffered frames, and stderr all drain after the parent exits. Observe the pending update promise before initiating shutdown as well, preventing a missing late frame from becoming a transient unhandled rejection before the assertion reports the fixture failure. --- .../support/acp-snapshot/tests/fixtures/fake-acp-agent.ts | 4 +++- packages/support/acp-snapshot/tests/harness.spec.ts | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/support/acp-snapshot/tests/fixtures/fake-acp-agent.ts b/packages/support/acp-snapshot/tests/fixtures/fake-acp-agent.ts index 5dd5524ed0..647ffbb5d9 100644 --- a/packages/support/acp-snapshot/tests/fixtures/fake-acp-agent.ts +++ b/packages/support/acp-snapshot/tests/fixtures/fake-acp-agent.ts @@ -266,7 +266,9 @@ function flushLogsAndExit(): void { `setTimeout(() => process.stdout.write(${JSON.stringify(`${frame}\n`)}), 50)`, `setTimeout(() => process.stderr.write(${JSON.stringify('late inherited stderr\n')}), 75)`, ].join(';') - spawn(process.execPath, ['-e', code], { stdio: ['ignore', 1, 2] }).unref() + spawn(process.execPath, ['-e', code], { + stdio: ['ignore', process.stdout, process.stderr], + }).unref() } process.exit(0) } diff --git a/packages/support/acp-snapshot/tests/harness.spec.ts b/packages/support/acp-snapshot/tests/harness.spec.ts index 2c4478e158..08b069338c 100644 --- a/packages/support/acp-snapshot/tests/harness.spec.ts +++ b/packages/support/acp-snapshot/tests/harness.spec.ts @@ -139,6 +139,9 @@ describe('runScenario', () => { update.sessionUpdate === 'agent_message_chunk' && update.content.type === 'text' && update.content.text === 'late inherited stdout') + // Arm rejection handling before close may exhaust the stream; the later assertion still + // observes the original promise and turns a missing inherited frame into the test failure. + void lateUpdate.catch(() => undefined) await launched.close()