From ec2d4e2f5c8efbc0985f27f2dc924eb388cfb243 Mon Sep 17 00:00:00 2001 From: Mason Reed Date: Wed, 16 Jul 2025 16:13:35 -0400 Subject: [Rust] Misc fixes / formatting - Fix cmake clean not cleaning target docs - Fix not prioritizing enterprise remote in collab tests - Some misc formatting - Fix incorrect assert in binary loading --- rust/tests/collaboration.rs | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'rust/tests/collaboration.rs') diff --git a/rust/tests/collaboration.rs b/rust/tests/collaboration.rs index 85f8702e..529e185b 100644 --- a/rust/tests/collaboration.rs +++ b/rust/tests/collaboration.rs @@ -18,7 +18,7 @@ fn temp_project_scope(remote: &Remote, project_name: &str // TODO: Because connecting is not thread safe we wont check the error here, this is because we might already // TODO: be connecting in some other thread and will error out on this thread. But we _probably_ will // TODO: have connected by the time this errors out. Maybe? - let _ = remote.connect(); + remote.connect().expect("Failed to connect to remote"); } let project = remote .create_project(project_name, "Test project for test purposes") @@ -50,13 +50,18 @@ fn temp_project_scope(remote: &Remote, project_name: &str /// Get the selected remote to test with. fn selected_remote() -> Option> { - // If the user has initialized with a enterprise server we might already have an active remote. + // TODO: Ability to override this with some environment variable? + // Assuming we already have called this we will have an active remote. match binaryninja::collaboration::active_remote() { Some(remote) => Some(remote), - None => { - let remotes = binaryninja::collaboration::known_remotes(); - remotes.iter().next().map(|r| r.clone()) - } + // Assuming the user is initialized with an enterprise client we should contact that one first. + None => match binaryninja::collaboration::enterprise_remote() { + Some(remote) => Some(remote), + None => { + let remotes = binaryninja::collaboration::known_remotes(); + remotes.iter().next().map(|r| r.clone()) + } + }, } } @@ -68,6 +73,13 @@ fn test_connection() { eprintln!("No known remotes, skipping test..."); return; }; + // Another test might have already connected. + if remote.is_connected() { + remote + .disconnect() + .expect("Failed to disconnect from remote"); + assert!(!remote.is_connected(), "Connection was not disconnected"); + } assert!(remote.connect().is_ok(), "Failed to connect to remote"); remote .disconnect() -- cgit v1.3.1