mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-09 10:56:20 +00:00
wip
This commit is contained in:
parent
a74c5073a4
commit
ce8dd5a286
1 changed files with 53 additions and 18 deletions
|
@ -48,15 +48,27 @@ enum ClientOperation {
|
||||||
AcceptIncomingCall,
|
AcceptIncomingCall,
|
||||||
RejectIncomingCall,
|
RejectIncomingCall,
|
||||||
LeaveCall,
|
LeaveCall,
|
||||||
InviteContactToCall { user_id: UserId },
|
InviteContactToCall {
|
||||||
OpenLocalProject { root: PathBuf },
|
user_id: UserId,
|
||||||
OpenRemoteProject { host_id: UserId, root: String },
|
},
|
||||||
AddWorktreeToProject { id: u64, new_path: PathBuf },
|
OpenLocalProject {
|
||||||
CloseProject { id: u64 },
|
first_root_path: PathBuf,
|
||||||
|
},
|
||||||
|
OpenRemoteProject {
|
||||||
|
host_id: UserId,
|
||||||
|
first_root_name: String,
|
||||||
|
},
|
||||||
|
AddWorktreeToProject {
|
||||||
|
first_root_path: PathBuf,
|
||||||
|
new_root_path: PathBuf,
|
||||||
|
},
|
||||||
|
CloseProject {
|
||||||
|
id: u64,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TestPlan {
|
impl TestPlan {
|
||||||
fn next_operation(
|
async fn next_operation(
|
||||||
&mut self,
|
&mut self,
|
||||||
clients: &[(Rc<TestClient>, TestAppContext)],
|
clients: &[(Rc<TestClient>, TestAppContext)],
|
||||||
offline_users: &[(UserId, String)],
|
offline_users: &[(UserId, String)],
|
||||||
|
@ -83,7 +95,7 @@ impl TestPlan {
|
||||||
let ix = self.rng.gen_range(0..clients.len());
|
let ix = self.rng.gen_range(0..clients.len());
|
||||||
let (client, cx) = &clients[ix];
|
let (client, cx) = &clients[ix];
|
||||||
let user_id = client.current_user_id(cx);
|
let user_id = client.current_user_id(cx);
|
||||||
let operation = self.next_client_operation(clients, ix);
|
let operation = self.next_client_operation(clients, ix).await;
|
||||||
Operation::MutateClient { user_id, operation }
|
Operation::MutateClient { user_id, operation }
|
||||||
}
|
}
|
||||||
_ => continue,
|
_ => continue,
|
||||||
|
@ -92,7 +104,7 @@ impl TestPlan {
|
||||||
operation
|
operation
|
||||||
}
|
}
|
||||||
|
|
||||||
fn next_client_operation(
|
async fn next_client_operation(
|
||||||
&mut self,
|
&mut self,
|
||||||
clients: &[(Rc<TestClient>, TestAppContext)],
|
clients: &[(Rc<TestClient>, TestAppContext)],
|
||||||
client_ix: usize,
|
client_ix: usize,
|
||||||
|
@ -157,17 +169,25 @@ impl TestPlan {
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
});
|
});
|
||||||
if !remote_projects.is_empty() {
|
if !remote_projects.is_empty() {
|
||||||
let (host_id, root) =
|
let (host_id, first_root_name) =
|
||||||
remote_projects.choose(&mut self.rng).unwrap().clone();
|
remote_projects.choose(&mut self.rng).unwrap().clone();
|
||||||
return ClientOperation::OpenRemoteProject { host_id, root };
|
return ClientOperation::OpenRemoteProject {
|
||||||
|
host_id,
|
||||||
|
first_root_name,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Open a local project
|
// Open a local project
|
||||||
50..=59 => {
|
50..=59 => {
|
||||||
let root = client.create_new_root_dir();
|
let paths = client.fs.paths().await;
|
||||||
return ClientOperation::OpenLocalProject { root };
|
let first_root_path = if paths.is_empty() || self.rng.gen() {
|
||||||
|
client.create_new_root_dir()
|
||||||
|
} else {
|
||||||
|
paths.choose(&mut self.rng).unwrap().clone()
|
||||||
|
};
|
||||||
|
return ClientOperation::OpenLocalProject { first_root_path };
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add a worktree to a local project
|
// Add a worktree to a local project
|
||||||
|
@ -178,12 +198,27 @@ impl TestPlan {
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.clone();
|
.clone();
|
||||||
|
|
||||||
// let paths = client.fs.paths().await;
|
let first_root_path = project.read_with(cx, |project, cx| {
|
||||||
// let path = paths.choose(&mut self.rng).unwrap();
|
project
|
||||||
|
.visible_worktrees(cx)
|
||||||
|
.next()
|
||||||
|
.unwrap()
|
||||||
|
.read(cx)
|
||||||
|
.abs_path()
|
||||||
|
.to_path_buf()
|
||||||
|
});
|
||||||
|
|
||||||
// if let Some(room) = call.read_with(cx, |call, _| call.room().cloned()) {
|
let paths = client.fs.paths().await;
|
||||||
// //
|
let new_root_path = if paths.is_empty() || self.rng.gen() {
|
||||||
// }
|
client.create_new_root_dir()
|
||||||
|
} else {
|
||||||
|
paths.choose(&mut self.rng).unwrap().clone()
|
||||||
|
};
|
||||||
|
|
||||||
|
return ClientOperation::AddWorktreeToProject {
|
||||||
|
first_root_path,
|
||||||
|
new_root_path,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
_ => continue,
|
_ => continue,
|
||||||
|
@ -260,7 +295,7 @@ async fn test_random_collaboration(
|
||||||
let mut next_entity_id = 100000;
|
let mut next_entity_id = 100000;
|
||||||
|
|
||||||
for _ in 0..max_operations {
|
for _ in 0..max_operations {
|
||||||
let next_operation = plan.lock().next_operation(&clients, &available_users);
|
let next_operation = plan.lock().next_operation(&clients, &available_users).await;
|
||||||
match next_operation {
|
match next_operation {
|
||||||
Operation::AddConnection { user_id } => {
|
Operation::AddConnection { user_id } => {
|
||||||
let user_ix = available_users
|
let user_ix = available_users
|
||||||
|
|
Loading…
Reference in a new issue