From b68867e3792728e1924c96d7f6312983976df14d Mon Sep 17 00:00:00 2001 From: Sayan Sisodiya Date: Mon, 2 Feb 2026 21:42:38 -0800 Subject: [PATCH] tests: harden compact_remote trim test timing on windows --- codex-rs/core/tests/suite/compact_remote.rs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/codex-rs/core/tests/suite/compact_remote.rs b/codex-rs/core/tests/suite/compact_remote.rs index b209d5b37f..fda3725fe6 100644 --- a/codex-rs/core/tests/suite/compact_remote.rs +++ b/codex-rs/core/tests/suite/compact_remote.rs @@ -23,7 +23,9 @@ use core_test_support::test_codex::TestCodexHarness; use core_test_support::test_codex::test_codex; use core_test_support::wait_for_event; use core_test_support::wait_for_event_match; +use core_test_support::wait_for_event_with_timeout; use pretty_assertions::assert_eq; +use tokio::time::Duration; #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn remote_compact_replaces_history_for_followups() -> Result<()> { @@ -232,7 +234,7 @@ async fn remote_compact_trims_function_call_history_to_fit_context_window() -> R let trimmed_call_id = "trimmed-call"; let retained_command = "echo retained-shell-output"; let trimmed_command = if cfg!(windows) { - "1..3000 | ForEach-Object { 'x' }" + "'x' * 50000" } else { "yes x | head -n 3000" }; @@ -260,7 +262,13 @@ async fn remote_compact_trims_function_call_history_to_fit_context_window() -> R responses::ev_completed("retained-final-response"), ]), sse(vec![ - responses::ev_shell_command_call(trimmed_call_id, trimmed_command), + responses::ev_shell_command_call_with_args( + trimmed_call_id, + &serde_json::json!({ + "command": trimmed_command, + "timeout_ms": 5_000, + }), + ), responses::ev_completed("trimmed-call-response"), ]), sse(vec![responses::ev_completed("trimmed-final-response")]), @@ -277,7 +285,12 @@ async fn remote_compact_trims_function_call_history_to_fit_context_window() -> R final_output_json_schema: None, }) .await?; - wait_for_event(&codex, |event| matches!(event, EventMsg::TurnComplete(_))).await; + wait_for_event_with_timeout( + &codex, + |event| matches!(event, EventMsg::TurnComplete(_)), + Duration::from_secs(20), + ) + .await; codex .submit(Op::UserInput {