Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.
Rust agentai-agentapplecomputer-usecomputer-use-agentcontainerizationcuadesktop-automationhacktoberfestlumemacosmanusoperatorswiftvirtualizationvirtualization-frameworkwindowswindows-sandbox
fix(cua-driver): bind every sdk test socket under a short /tmp dir (#6466)
injaneity568e07806bad
diff --git a/libs/cua-driver/rust/crates/cua-driver-sdk/src/embedded.rs b/libs/cua-driver/rust/crates/cua-driver-sdk/src/embedded.rsindex 266078c82d..0767524f36 100644--- a/libs/cua-driver/rust/crates/cua-driver-sdk/src/embedded.rs+++ b/libs/cua-driver/rust/crates/cua-driver-sdk/src/embedded.rs@@ -1763,7 +1763,7 @@ mod tests {#[cfg(unix)]#[test]fn endpoint_preflight_refuses_non_socket_paths() {- let directory = tempfile::tempdir().unwrap();+ let directory = crate::socket_tempdir();let file = directory.path().join("important.txt");std::fs::write(&file, "keep").unwrap();let error = prepare_endpoint(file.to_str().unwrap()).unwrap_err();@@ -1791,7 +1791,7 @@ mod tests {"com.example.cancel-stop".into(),).unwrap();- let directory = tempfile::tempdir().unwrap();+ let directory = crate::socket_tempdir();let socket_path = directory.path().join("driver.sock");let listener = std::os::unix::net::UnixListener::bind(&socket_path).unwrap();std::fs::set_permissions(diff --git a/libs/cua-driver/rust/crates/cua-driver-sdk/src/lib.rs b/libs/cua-driver/rust/crates/cua-driver-sdk/src/lib.rsindex db9010199f..cfdbd30168 100644--- a/libs/cua-driver/rust/crates/cua-driver-sdk/src/lib.rs+++ b/libs/cua-driver/rust/crates/cua-driver-sdk/src/lib.rs@@ -2043,6 +2043,16 @@ fn normalize_result(tool: &str, raw: Value) -> Result<ToolResult, DriverError> {uniffi::setup_scaffolding!("cua_driver_sdk");+/// Test directory for Unix socket endpoints. sun_path holds 104 bytes on+/// macOS and a long TMPDIR can use most of it, so tests bind under /tmp.+#[cfg(all(test, unix))]+fn socket_tempdir() -> tempfile::TempDir {+ tempfile::Builder::new()+ .prefix("cd")+ .tempdir_in("/tmp")+ .unwrap()+}+#[cfg(test)]#[path = "tests/snapshot_lifecycle.rs"]mod snapshot_lifecycle_tests;@@ -2092,13 +2102,9 @@ mod tests {#[cfg(unix)]fn serve_once(response: Value) -> (tempfile::TempDir, String, std::thread::JoinHandle<Value>) {- // Short path under /tmp: sun_path holds ~104 bytes on macOS and a CI- // TMPDIR can eat most of it. The listener is bound before returning,- // so the client needs no readiness wait.- let directory = tempfile::Builder::new()- .prefix("cd")- .tempdir_in("/tmp")- .unwrap();+ // The listener is bound before returning, so the client needs no+ // readiness wait.+ let directory = crate::socket_tempdir();let socket = directory.path().join("d.sock");let listener = UnixListener::bind(&socket).unwrap();let handle = std::thread::spawn(move || {@@ -3073,7 +3079,7 @@ mod tests {#[tokio::test]#[cfg(unix)]async fn daemon_version_mismatch_is_refused_before_action_dispatch() {- let directory = tempfile::tempdir().unwrap();+ let directory = crate::socket_tempdir();let socket = directory.path().join("incompatible.sock");let listener = UnixListener::bind(&socket).unwrap();let action_dispatched = Arc::new(std::sync::atomic::AtomicBool::new(false));diff --git a/libs/cua-driver/rust/crates/cua-driver-sdk/src/service_session.rs b/libs/cua-driver/rust/crates/cua-driver-sdk/src/service_session.rsindex 86c7c2a471..f1b7ad1230 100644--- a/libs/cua-driver/rust/crates/cua-driver-sdk/src/service_session.rs+++ b/libs/cua-driver/rust/crates/cua-driver-sdk/src/service_session.rs@@ -437,7 +437,7 @@ mod tests {#[tokio::test]async fn next_call_resumes_with_single_use_host_credential_after_disconnect() {- let directory = tempfile::tempdir().unwrap();+ let directory = crate::socket_tempdir();let socket = directory.path().join("resumable-service.sock");let listener = UnixListener::bind(&socket).unwrap();let server = std::thread::spawn(move || {@@ -553,7 +553,7 @@ mod tests {#[tokio::test]async fn transient_read_timeouts_are_poll_intervals_not_action_deadlines() {- let directory = tempfile::tempdir().unwrap();+ let directory = crate::socket_tempdir();let socket = directory.path().join("delayed-service.sock");let listener = UnixListener::bind(&socket).unwrap();let server = std::thread::spawn(move || {