diff --git a/cli/src/native/browser.rs b/cli/src/native/browser.rs index 9fd23b57aa..15f79831fc 100644 --- a/cli/src/native/browser.rs +++ b/cli/src/native/browser.rs @@ -4379,13 +4379,15 @@ mod tests { // Keep sending requests so idle is never reached tokio::spawn(async move { - for i in 0u64.. { + let mut i = 0u64; + loop { let _ = tx.send(cdp_event( "Network.requestWillBeSent", session, json!({ "requestId": format!("r{}", i) }), )); sleep(Duration::from_millis(100)).await; + i = i.wrapping_add(1); } }); diff --git a/cli/src/native/cdp/client.rs b/cli/src/native/cdp/client.rs index 1cd6ed91c5..b9ddf8b560 100644 --- a/cli/src/native/cdp/client.rs +++ b/cli/src/native/cdp/client.rs @@ -1249,6 +1249,7 @@ mod tests { } #[tokio::test] + #[allow(clippy::result_large_err)] async fn root_websocket_url_with_query_sends_slash_request_target() { let listener = TcpListener::bind("127.0.0.1:0").await.unwrap(); let port = listener.local_addr().unwrap().port(); diff --git a/cli/src/native/e2e_tests.rs b/cli/src/native/e2e_tests.rs index d24b68fc81..1bac35da16 100644 --- a/cli/src/native/e2e_tests.rs +++ b/cli/src/native/e2e_tests.rs @@ -9102,7 +9102,7 @@ async fn e2e_recording_cursor_stays_aligned_during_drag() { let mut measured = 0; let mut worst = 0; let mut positions = std::collections::HashSet::new(); - for bytes in output.stdout.chunks_exact(640 * 80 * 3) { + for bytes in output.stdout.as_chunks::<{ 640 * 80 * 3 }>().0 { let frame = image::RgbImage::from_raw(640, 80, bytes.to_vec()).unwrap(); let line = (0..640).find(|&x| { let [r, g, b] = frame.get_pixel(x, 0).0; diff --git a/cli/tests/dashboard_cli.rs b/cli/tests/dashboard_cli.rs index 571e8124e2..8ad3ea321d 100644 --- a/cli/tests/dashboard_cli.rs +++ b/cli/tests/dashboard_cli.rs @@ -4,6 +4,7 @@ use serde_json::Value; use std::io::{Read, Write}; use std::net::{Ipv4Addr, Ipv6Addr, SocketAddr, TcpListener, TcpStream}; use std::process::{Child, Command, Output, Stdio}; +use std::sync::atomic::{AtomicUsize, Ordering}; use std::thread; use std::time::{Duration, Instant}; use tempfile::TempDir; @@ -94,17 +95,38 @@ fn seed_running_dashboard(tmp: &TempDir, port: u16, allowed_origins: &[&str]) -> RunningDashboard(child) } +/// Runs the CLI with stdout/stderr redirected to files instead of pipes. +/// +/// `dashboard start` leaves a detached server running. On Windows that server +/// inherits the CLI's inheritable handles, including the write ends of the +/// pipes `Command::output()` creates, so `output()` never sees EOF and the +/// test hangs until the server dies. Files have no EOF to wait for. fn run_dashboard(tmp: &TempDir, args: &[&str]) -> Output { + static RUN: AtomicUsize = AtomicUsize::new(0); let socket_dir = socket_dir(tmp); std::fs::create_dir_all(&socket_dir).unwrap(); + let capture_dir = tmp.path().join("capture"); + std::fs::create_dir_all(&capture_dir).unwrap(); + let id = RUN.fetch_add(1, Ordering::SeqCst); + let out_path = capture_dir.join(format!("{id}.stdout")); + let err_path = capture_dir.join(format!("{id}.stderr")); - Command::new(BIN) + let status = Command::new(BIN) .args(args) .env("AGENT_BROWSER_SOCKET_DIR", socket_dir) .env_remove("AGENT_BROWSER_DASHBOARD_ALLOWED_ORIGINS") .env("NO_COLOR", "1") - .output() - .expect("failed to invoke agent-browser dashboard") + .stdin(Stdio::null()) + .stdout(std::fs::File::create(&out_path).unwrap()) + .stderr(std::fs::File::create(&err_path).unwrap()) + .status() + .expect("failed to invoke agent-browser dashboard"); + + Output { + status, + stdout: std::fs::read(&out_path).unwrap_or_default(), + stderr: std::fs::read(&err_path).unwrap_or_default(), + } } fn json_output(output: &Output) -> Value {