Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Fix flaky terminal kill test (#52370)
Mikayla Maki0512b72106f7
diff --git a/crates/acp_thread/src/acp_thread.rs b/crates/acp_thread/src/acp_thread.rsindex 3b143efbfdb..2195f9e73ef 100644--- a/crates/acp_thread/src/acp_thread.rs+++ b/crates/acp_thread/src/acp_thread.rs@@ -3177,9 +3177,27 @@ mod tests {);});- // Wait for the printf command to execute and produce output- // Use real time since parking is enabled- cx.executor().timer(Duration::from_millis(500)).await;+ // Poll until the printf command produces output, rather than using a+ // fixed sleep which is flaky on loaded machines.+ let deadline = std::time::Instant::now() + Duration::from_secs(10);+ loop {+ let has_output = thread.read_with(cx, |thread, cx| {+ let term = thread+ .terminals+ .get(&terminal_id)+ .expect("terminal not found");+ let content = term.read(cx).inner().read(cx).get_content();+ content.contains("output_before_kill")+ });+ if has_output {+ break;+ }+ assert!(+ std::time::Instant::now() < deadline,+ "Timed out waiting for printf output to appear in terminal",+ );+ cx.executor().timer(Duration::from_millis(50)).await;+ }// Get the acp_thread Terminal and kill itlet wait_for_exit = thread.update(cx, |thread, cx| {