From ada131a0aa1852c9c859a07338ab01df81d751cd Mon Sep 17 00:00:00 2001 From: Val Alexander <68980965+BunsDev@users.noreply.github.com> Date: Sat, 18 Jul 2026 04:41:56 -0500 Subject: [PATCH] test: copy shim stdin with findstr instead of PowerShell (deflake #407) The fake-codex batch shims copied stdin via PowerShell, whose cold start on a loaded windows-latest runner outlived even the 10s activity deadline (#402's headroom fix) and flaked codex_json_batch_shim_uses_stdin_and_emits_assistant_text again on PR #422 with the same os error 2. findstr is a native always-present binary with no cold start; "^" matches every line, so it copies stdin verbatim until EOF. Applied to both the pty_runner unit shim and the stream_json_integration fixture; the 10s deadline stays as generic startup headroom. Fixes #407 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- crates/coven-cli/src/pty_runner.rs | 12 ++++++++---- crates/coven-cli/tests/stream_json_integration.rs | 4 +++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/crates/coven-cli/src/pty_runner.rs b/crates/coven-cli/src/pty_runner.rs index ad37190a..c72f9401 100644 --- a/crates/coven-cli/src/pty_runner.rs +++ b/crates/coven-cli/src/pty_runner.rs @@ -3511,11 +3511,15 @@ exit 0 fn codex_json_batch_shim_uses_stdin_and_emits_assistant_text() -> anyhow::Result<()> { let temp_dir = tempfile::tempdir()?; let batch = temp_dir.path().join("fake-codex.cmd"); + // Copy stdin with findstr (a native, always-present binary with no + // cold start): PowerShell's multi-second startup on loaded runners + // outlived even a 10s activity deadline and flaked this test twice + // (issue #407). std::fs::write( &batch, concat!( "@echo off\r\n", - "\"%SystemRoot%\\System32\\WindowsPowerShell\\v1.0\\powershell.exe\" -NoProfile -Command \"$inputStream=[Console]::OpenStandardInput(); $outputStream=[IO.File]::Open('stdin.txt',[IO.FileMode]::Create); $inputStream.CopyTo($outputStream); $outputStream.Dispose()\"\r\n", + "\"%SystemRoot%\\System32\\findstr.exe\" \"^\" > stdin.txt\r\n", "echo %* > args.txt\r\n", "echo {\"type\":\"thread.started\",\"thread_id\":\"thread-456\"}\r\n", "echo {\"type\":\"item.completed\",\"item\":{\"id\":\"item-1\",\"type\":\"agent_message\",\"text\":\"reply from Codex\"}}\r\n", @@ -3536,9 +3540,9 @@ exit 0 }; let mut assistant = Vec::new(); - // PowerShell can take several seconds to cold-start on a loaded - // Windows runner. This test exercises stdin and JSONL framing, not the - // activity deadline, so leave enough headroom for process startup. + // Generous headroom for shim process startup on a loaded Windows + // runner (issue #407). This test exercises stdin and JSONL framing, + // not the activity deadline. let outcome = stream_codex_json_with_timeout(&command, Duration::from_secs(10), |text| { assistant.push(text.to_string()); Ok(()) diff --git a/crates/coven-cli/tests/stream_json_integration.rs b/crates/coven-cli/tests/stream_json_integration.rs index 9779eb92..41fbe838 100644 --- a/crates/coven-cli/tests/stream_json_integration.rs +++ b/crates/coven-cli/tests/stream_json_integration.rs @@ -512,7 +512,9 @@ description = "Windows Codex regression fixture" &fake_codex, concat!( "@echo off\r\n", - "\"%SystemRoot%\\System32\\WindowsPowerShell\\v1.0\\powershell.exe\" -NoProfile -Command \"$inputStream=[Console]::OpenStandardInput(); $outputStream=[IO.File]::Open('stdin.txt',[IO.FileMode]::Create); $inputStream.CopyTo($outputStream); $outputStream.Dispose()\"\r\n", + // findstr copies stdin without PowerShell's multi-second cold + // start, which flaked the sibling pty_runner test (issue #407). + "\"%SystemRoot%\\System32\\findstr.exe\" \"^\" > stdin.txt\r\n", "echo %* > args.txt\r\n", "echo {\"type\":\"thread.started\",\"thread_id\":\"thread-789\"}\r\n", "echo {\"type\":\"turn.started\"}\r\n",