Skip to content

Commit 01b4e53

Browse files
committed
test(tui): stabilize stuck exec flush timing
1 parent 455ed63 commit 01b4e53

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

code-rs/tui/tests/stuck_exec.rs

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use code_tui::test_helpers::{render_chat_widget_to_vt100, ChatWidgetHarness};
1818
use std::collections::HashMap;
1919
use std::path::PathBuf;
2020
use std::time::Duration;
21+
use std::time::Instant;
2122

2223
fn next_order_meta(request_ordinal: u64, seq: &mut u64) -> OrderMeta {
2324
let order = OrderMeta {
@@ -428,7 +429,10 @@ fn queued_exec_end_flushes_after_stream_clears() {
428429
// Stream finishes before the idle-flush callback fires; pending ExecEnd should still flush.
429430
harness.force_stream_clear();
430431

431-
std::thread::sleep(Duration::from_millis(250));
432+
// Give the flush timers enough headroom under nextest parallelism.
433+
std::thread::sleep(Duration::from_millis(400));
434+
harness.flush_into_widget();
435+
std::thread::sleep(Duration::from_millis(200));
432436
harness.flush_into_widget();
433437

434438
let output = render_chat_widget_to_vt100(&mut harness, 80, 14);
@@ -492,15 +496,19 @@ fn background_style_exec_end_with_zero_seq_does_not_get_stuck() {
492496
harness.force_stream_clear();
493497

494498
// Flush queued interrupts to deliver begin/end.
495-
std::thread::sleep(Duration::from_millis(250));
496-
harness.flush_into_widget();
497-
498-
let output = render_chat_widget_to_vt100(&mut harness, 80, 12);
499-
assert!(
500-
output.contains("bg") && !output.contains("Running..."),
501-
"exec with zero seq end should complete after flush:\n{}",
502-
output
503-
);
499+
let deadline = Instant::now() + Duration::from_secs(2);
500+
let mut output;
501+
loop {
502+
std::thread::sleep(Duration::from_millis(100));
503+
harness.flush_into_widget();
504+
output = render_chat_widget_to_vt100(&mut harness, 80, 12);
505+
if output.contains("bg") && !output.contains("Running...") {
506+
break;
507+
}
508+
if Instant::now() >= deadline {
509+
panic!("exec with zero seq end should complete after flush:\n{}", output);
510+
}
511+
}
504512
}
505513

506514
#[test]

0 commit comments

Comments
 (0)