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
4 changes: 3 additions & 1 deletion cli/src/native/browser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
});

Expand Down
1 change: 1 addition & 0 deletions cli/src/native/cdp/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion cli/src/native/e2e_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
28 changes: 25 additions & 3 deletions cli/tests/dashboard_cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down
Loading