Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions cmux-tui/crates/cmux-tui-core/tests/browser_runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,12 +229,12 @@ fn recv_attach_event(reader: &mut BufReader<UnixStream>, event: &str) -> Value {
}

fn wait_for<T>(mut f: impl FnMut() -> Option<T>, timeout: Duration) -> Option<T> {
let start = Instant::now();
let deadline = Instant::now() + test_duration(timeout);
loop {
if let Some(value) = f() {
return Some(value);
}
if start.elapsed() > timeout {
if Instant::now() >= deadline {
return None;
}
thread::sleep(Duration::from_millis(20));
Expand Down Expand Up @@ -1537,7 +1537,7 @@ fn browser_capture_scale_applies_to_metrics_screencast_and_input() {
let frame_seq = surface.browser_frame_seq()?;
(frame.seq == frame_seq).then_some((frame, frame_seq))
},
test_duration(Duration::from_secs(10)),
Duration::from_secs(10),
)
.expect("browser produced a pointer-authoritative frame");
assert_eq!(frame.data_b64, "c2NhbGU=");
Expand Down
18 changes: 17 additions & 1 deletion cmux-tui/crates/cmux-tui/tests/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3613,8 +3613,24 @@ fn assert_subscribe_reports_tree_changed(server: &HeadlessServer) {
}
});
writeln!(writer, r#"{{"id":1,"cmd":"subscribe"}}"#).unwrap();
writer.flush().unwrap();

let deadline = Instant::now() + Duration::from_secs(5);
loop {
let remaining = deadline
.checked_duration_since(Instant::now())
.expect("server did not acknowledge the tree-change subscription");
let line = rx
.recv_timeout(remaining)
.expect("server did not acknowledge the tree-change subscription");
let message: serde_json::Value =
serde_json::from_str(&line).expect("subscription returned invalid JSON");
if message["id"].as_u64() == Some(1) {
assert_eq!(message["ok"], true, "tree-change subscription failed: {message}");
break;
}
}

std::thread::sleep(Duration::from_millis(200));
let tab = json_cli(server, &["tab", "create", "terminal"]);
if !tab.status.success() {
let mut lines = Vec::new();
Expand Down
6 changes: 3 additions & 3 deletions cmux-tui/crates/cmux-tui/tests/terminal_host_recovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3807,7 +3807,7 @@ fn wait_for_socket(path: &Path) {
}

fn wait_for_screen(path: &Path, surface: u64, marker: &str) -> String {
let deadline = Instant::now() + Duration::from_secs(10);
let deadline = Instant::now() + test_timeout(Duration::from_secs(10));
let mut last = String::new();
while Instant::now() < deadline {
last = request(path, serde_json::json!({"cmd": "read-screen", "surface": surface}))["text"]
Expand All @@ -3823,7 +3823,7 @@ fn wait_for_screen(path: &Path, surface: u64, marker: &str) -> String {
}

fn wait_for_host_records(root: &Path, expected: usize) -> Vec<(PathBuf, TerminalHostRecord)> {
let deadline = Instant::now() + Duration::from_secs(10);
let deadline = Instant::now() + test_timeout(Duration::from_secs(10));
loop {
let records = load_terminal_host_records(root).unwrap();
if records.len() == expected {
Expand All @@ -3835,7 +3835,7 @@ fn wait_for_host_records(root: &Path, expected: usize) -> Vec<(PathBuf, Terminal
}

fn wait_for_no_host_records(root: &Path) {
let deadline = Instant::now() + Duration::from_secs(10);
let deadline = Instant::now() + test_timeout(Duration::from_secs(10));
while Instant::now() < deadline {
if load_terminal_host_records(root).unwrap().is_empty()
&& load_terminal_host_exit_records(root).unwrap().is_empty()
Expand Down
Loading