Lightweight coding agent that runs in your terminal
Rust
Handle completion events in either order in shell snapshot tests (#52660)
jifb49e2211a579
diff --git a/codex-rs/core/tests/suite/shell_snapshot.rs b/codex-rs/core/tests/suite/shell_snapshot.rsindex 8bfd272c10..4be1c96bec 100644--- a/codex-rs/core/tests/suite/shell_snapshot.rs+++ b/codex-rs/core/tests/suite/shell_snapshot.rs@@ -299,13 +299,17 @@ async fn run_tool_turn_on_harness(_ => None,}).await;- let end = wait_for_event_match(&codex, |ev| match ev {- EventMsg::ExecCommandEnd(ev) if ev.call_id == call_id => Some(ev.clone()),- _ => None,- })- .await;- wait_for_event(&codex, |ev| matches!(ev, EventMsg::TurnComplete(_))).await;- Ok(end)+ let mut end = None;+ let mut turn_completed = false;+ // The tool can return before its background watcher emits command-end.+ while end.is_none() || !turn_completed {+ match wait_for_event(&codex, |_| true).await {+ EventMsg::ExecCommandEnd(ev) if ev.call_id == call_id => end = Some(ev),+ EventMsg::TurnComplete(_) => turn_completed = true,+ _ => {}+ }+ }+ Ok(end.expect("command-end should have arrived before completing the wait"))}fn normalize_newlines(text: &str) -> String {