MCPcopy Create free account
hub / github.com/Vector35/binaryninja-api / temp_project_scope

Function temp_project_scope

rust/tests/collaboration.rs:16–56  ·  view source on GitHub ↗
(remote: &Remote, project_name: &str, cb: T)

Source from the content-addressed store, hash-verified

14// TODO: Real code shouldnt be trying to connect to the same remote on multiple threads.
15
16fn temp_project_scope<T: Fn(&RemoteProject)>(remote: &Remote, project_name: &str, cb: T) {
17 if !remote.is_connected() {
18 // TODO: Because connecting is not thread safe we wont check the error here, this is because we might already
19 // TODO: be connecting in some other thread and will error out on this thread. But we _probably_ will
20 // TODO: have connected by the time this errors out. Maybe?
21 let _ = remote.connect();
22 }
23
24 if let Ok(home_dir) = env::var("HOME").or_else(|_| env::var("USERPROFILE")) {
25 eprintln!("Current user directory: {}", home_dir);
26 } else {
27 eprintln!("Unable to determine the current user directory.");
28 }
29
30 let project = remote
31 .create_project(project_name, "Test project for test purposes")
32 .expect("Failed to create project");
33 project.open().expect("Failed to open project");
34 assert!(project.is_open(), "Project was not opened");
35 // Clear out all the possible entries. This is to insure a clean slate.
36 let files = project.files().expect("Failed to list files in project");
37 for file in &files {
38 project.delete_file(&file).expect("Failed to delete file");
39 }
40 let folders = project
41 .folders()
42 .expect("Failed to list folders in project");
43 for folder in &folders {
44 project
45 .delete_folder(&folder)
46 .expect("Failed to delete folder");
47 }
48 // Run task
49 cb(&project);
50 // Cleanup.
51 project.close();
52 assert!(!project.is_open(), "Project was not closed");
53 remote
54 .delete_project(&project)
55 .expect("Failed to delete project");
56}
57
58/// Get the selected remote to test with.
59fn selected_remote() -> Option<Ref<Remote>> {

Callers 2

test_project_creationFunction · 0.85
test_project_syncFunction · 0.85

Calls 10

is_connectedMethod · 0.45
connectMethod · 0.45
create_projectMethod · 0.45
openMethod · 0.45
filesMethod · 0.45
delete_fileMethod · 0.45
foldersMethod · 0.45
delete_folderMethod · 0.45
closeMethod · 0.45
delete_projectMethod · 0.45

Tested by

no test coverage detected