Skip to content

Commit 8cb48ba

Browse files
vorporealoz-agent
andauthored
Reduce flakiness of windows local_tty test. (warpdotdev#12881)
## Description The Windows child-exit test used a one-shot 200 ms Mio poll after asynchronously terminating `cmd.exe`. Under load, Windows can take longer to signal the process handle, run the registered wait callback, and wake Mio, causing the test to unwrap an empty event set. Use a generous overall deadline and repeatedly poll until the channel token is observed. Successful runs still return immediately, while timeout failures now report the receiver state to distinguish delayed callback delivery from a lost Mio wake. ## Linked Issue N/A — test-only CI flake reduction. ## Testing - `cargo fmt --all -- --check` - `cargo check -p warp --tests` - `git diff --check` - Not run locally: `cargo nextest run -p warp -E 'test(test_event_is_emitted_when_child_exits)'` because the test is Windows-only and the current host is macOS. ## Agent Mode - [x] Warp Agent Mode - This PR was created via Warp's AI Agent Mode CHANGELOG-NONE Co-Authored-By: Oz <oz-agent@warp.dev>
1 parent f84c6ca commit 8cb48ba

1 file changed

Lines changed: 22 additions & 4 deletions

File tree

app/src/terminal/local_tty/windows/child_tests.rs

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@ use std::os::windows::io::AsRawHandle;
22
use std::time::Duration;
33

44
use command::blocking::Command;
5+
use instant::Instant;
56

67
use super::*;
78
use crate::terminal::local_tty::event_loop::CHANNEL_TOKEN;
89

910
#[test]
1011
pub fn test_event_is_emitted_when_child_exits() {
11-
const WAIT_TIMEOUT: Duration = Duration::from_millis(200);
12+
const WAIT_TIMEOUT: Duration = Duration::from_secs(10);
1213

1314
let mut poll = mio::Poll::new().unwrap();
1415

@@ -28,10 +29,27 @@ pub fn test_event_is_emitted_when_child_exits() {
2829

2930
child.kill().unwrap();
3031

31-
// Poll for the event or fail with timeout if nothing has been sent.
32+
// Poll until the event arrives or the overall timeout elapses.
3233
let mut events = mio::Events::with_capacity(10);
33-
poll.poll(&mut events, Some(WAIT_TIMEOUT)).unwrap();
34-
assert_eq!(events.iter().next().unwrap().token(), CHANNEL_TOKEN);
34+
let deadline = Instant::now() + WAIT_TIMEOUT;
35+
loop {
36+
events.clear();
37+
poll.poll(
38+
&mut events,
39+
Some(deadline.saturating_duration_since(Instant::now())),
40+
)
41+
.unwrap();
42+
43+
if events.iter().any(|event| event.token() == CHANNEL_TOKEN) {
44+
break;
45+
}
46+
47+
assert!(
48+
Instant::now() < deadline,
49+
"timed out waiting for child-exit event; receiver state: {:?}",
50+
rx.try_recv()
51+
);
52+
}
3553
// Verify that at least one `ChildEvent::Exited` was received.
3654
assert!(matches!(rx.try_recv(), Ok(Message::ChildExited)));
3755
}

0 commit comments

Comments
 (0)