From 0512b72106f7d996cac24d8a4215c7a986f1063e Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Wed, 25 Mar 2026 08:33:56 -0700 Subject: [PATCH] Fix flaky terminal kill test (#52370) ## Context This test was bugging me, so I had claude take a look at it. ## Self-Review Checklist - [x] I've reviewed my own diff for quality, security, and reliability - [x] Unsafe blocks (if any) have justifying comments - [x] The content is consistent with the [UI/UX checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) - [x] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable Release Notes: - N/A --- crates/acp_thread/src/acp_thread.rs | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/crates/acp_thread/src/acp_thread.rs b/crates/acp_thread/src/acp_thread.rs index 3b143efbfdbd9c1ef636f76db795cd2f5b3b43e7..2195f9e73ef085bdbaf91aaec6e42383f533ee8f 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 it let wait_for_exit = thread.update(cx, |thread, cx| {