windows: Enable collab tests (#27587)

Release Notes:

- N/A
This commit is contained in:
张小白 2025-03-27 20:42:22 +08:00 committed by GitHub
parent 71ddb3dad4
commit 06960670bd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 277 additions and 234 deletions

View file

@ -1,6 +1,3 @@
// todo(windows): Actually run the tests
#![cfg(not(target_os = "windows"))]
use std::sync::Arc; use std::sync::Arc;
use call::Room; use call::Room;

View file

@ -36,6 +36,7 @@ use std::{
}, },
}; };
use text::Point; use text::Point;
use util::{path, uri};
use workspace::{CloseIntent, Workspace}; use workspace::{CloseIntent, Workspace};
#[gpui::test(iterations = 10)] #[gpui::test(iterations = 10)]
@ -190,9 +191,9 @@ async fn test_newline_above_or_below_does_not_move_guest_cursor(
client_a client_a
.fs() .fs()
.insert_tree("/dir", json!({ "a.txt": "Some text\n" })) .insert_tree(path!("/dir"), json!({ "a.txt": "Some text\n" }))
.await; .await;
let (project_a, worktree_id) = client_a.build_local_project("/dir", cx_a).await; let (project_a, worktree_id) = client_a.build_local_project(path!("/dir"), cx_a).await;
let project_id = active_call_a let project_id = active_call_a
.update(cx_a, |call, cx| call.share_project(project_a.clone(), cx)) .update(cx_a, |call, cx| call.share_project(project_a.clone(), cx))
.await .await
@ -306,14 +307,14 @@ async fn test_collaborating_with_completion(cx_a: &mut TestAppContext, cx_b: &mu
client_a client_a
.fs() .fs()
.insert_tree( .insert_tree(
"/a", path!("/a"),
json!({ json!({
"main.rs": "fn main() { a }", "main.rs": "fn main() { a }",
"other.rs": "", "other.rs": "",
}), }),
) )
.await; .await;
let (project_a, worktree_id) = client_a.build_local_project("/a", cx_a).await; let (project_a, worktree_id) = client_a.build_local_project(path!("/a"), cx_a).await;
let project_id = active_call_a let project_id = active_call_a
.update(cx_a, |call, cx| call.share_project(project_a.clone(), cx)) .update(cx_a, |call, cx| call.share_project(project_a.clone(), cx))
.await .await
@ -351,7 +352,7 @@ async fn test_collaborating_with_completion(cx_a: &mut TestAppContext, cx_b: &mu
.set_request_handler::<lsp::request::Completion, _, _>(|params, _| async move { .set_request_handler::<lsp::request::Completion, _, _>(|params, _| async move {
assert_eq!( assert_eq!(
params.text_document_position.text_document.uri, params.text_document_position.text_document.uri,
lsp::Url::from_file_path("/a/main.rs").unwrap(), lsp::Url::from_file_path(path!("/a/main.rs")).unwrap(),
); );
assert_eq!( assert_eq!(
params.text_document_position.position, params.text_document_position.position,
@ -468,7 +469,7 @@ async fn test_collaborating_with_completion(cx_a: &mut TestAppContext, cx_b: &mu
.set_request_handler::<lsp::request::Completion, _, _>(|params, _| async move { .set_request_handler::<lsp::request::Completion, _, _>(|params, _| async move {
assert_eq!( assert_eq!(
params.text_document_position.text_document.uri, params.text_document_position.text_document.uri,
lsp::Url::from_file_path("/a/main.rs").unwrap(), lsp::Url::from_file_path(path!("/a/main.rs")).unwrap(),
); );
assert_eq!( assert_eq!(
params.text_document_position.position, params.text_document_position.position,
@ -562,14 +563,14 @@ async fn test_collaborating_with_code_actions(
client_a client_a
.fs() .fs()
.insert_tree( .insert_tree(
"/a", path!("/a"),
json!({ json!({
"main.rs": "mod other;\nfn main() { let foo = other::foo(); }", "main.rs": "mod other;\nfn main() { let foo = other::foo(); }",
"other.rs": "pub fn foo() -> usize { 4 }", "other.rs": "pub fn foo() -> usize { 4 }",
}), }),
) )
.await; .await;
let (project_a, worktree_id) = client_a.build_local_project("/a", cx_a).await; let (project_a, worktree_id) = client_a.build_local_project(path!("/a"), cx_a).await;
let project_id = active_call_a let project_id = active_call_a
.update(cx_a, |call, cx| call.share_project(project_a.clone(), cx)) .update(cx_a, |call, cx| call.share_project(project_a.clone(), cx))
.await .await
@ -592,7 +593,7 @@ async fn test_collaborating_with_code_actions(
.set_request_handler::<lsp::request::CodeActionRequest, _, _>(|params, _| async move { .set_request_handler::<lsp::request::CodeActionRequest, _, _>(|params, _| async move {
assert_eq!( assert_eq!(
params.text_document.uri, params.text_document.uri,
lsp::Url::from_file_path("/a/main.rs").unwrap(), lsp::Url::from_file_path(path!("/a/main.rs")).unwrap(),
); );
assert_eq!(params.range.start, lsp::Position::new(0, 0)); assert_eq!(params.range.start, lsp::Position::new(0, 0));
assert_eq!(params.range.end, lsp::Position::new(0, 0)); assert_eq!(params.range.end, lsp::Position::new(0, 0));
@ -614,7 +615,7 @@ async fn test_collaborating_with_code_actions(
.set_request_handler::<lsp::request::CodeActionRequest, _, _>(|params, _| async move { .set_request_handler::<lsp::request::CodeActionRequest, _, _>(|params, _| async move {
assert_eq!( assert_eq!(
params.text_document.uri, params.text_document.uri,
lsp::Url::from_file_path("/a/main.rs").unwrap(), lsp::Url::from_file_path(path!("/a/main.rs")).unwrap(),
); );
assert_eq!(params.range.start, lsp::Position::new(1, 31)); assert_eq!(params.range.start, lsp::Position::new(1, 31));
assert_eq!(params.range.end, lsp::Position::new(1, 31)); assert_eq!(params.range.end, lsp::Position::new(1, 31));
@ -626,7 +627,7 @@ async fn test_collaborating_with_code_actions(
changes: Some( changes: Some(
[ [
( (
lsp::Url::from_file_path("/a/main.rs").unwrap(), lsp::Url::from_file_path(path!("/a/main.rs")).unwrap(),
vec![lsp::TextEdit::new( vec![lsp::TextEdit::new(
lsp::Range::new( lsp::Range::new(
lsp::Position::new(1, 22), lsp::Position::new(1, 22),
@ -636,7 +637,7 @@ async fn test_collaborating_with_code_actions(
)], )],
), ),
( (
lsp::Url::from_file_path("/a/other.rs").unwrap(), lsp::Url::from_file_path(path!("/a/other.rs")).unwrap(),
vec![lsp::TextEdit::new( vec![lsp::TextEdit::new(
lsp::Range::new( lsp::Range::new(
lsp::Position::new(0, 0), lsp::Position::new(0, 0),
@ -697,7 +698,7 @@ async fn test_collaborating_with_code_actions(
changes: Some( changes: Some(
[ [
( (
lsp::Url::from_file_path("/a/main.rs").unwrap(), lsp::Url::from_file_path(path!("/a/main.rs")).unwrap(),
vec![lsp::TextEdit::new( vec![lsp::TextEdit::new(
lsp::Range::new( lsp::Range::new(
lsp::Position::new(1, 22), lsp::Position::new(1, 22),
@ -707,7 +708,7 @@ async fn test_collaborating_with_code_actions(
)], )],
), ),
( (
lsp::Url::from_file_path("/a/other.rs").unwrap(), lsp::Url::from_file_path(path!("/a/other.rs")).unwrap(),
vec![lsp::TextEdit::new( vec![lsp::TextEdit::new(
lsp::Range::new( lsp::Range::new(
lsp::Position::new(0, 0), lsp::Position::new(0, 0),
@ -780,14 +781,14 @@ async fn test_collaborating_with_renames(cx_a: &mut TestAppContext, cx_b: &mut T
client_a client_a
.fs() .fs()
.insert_tree( .insert_tree(
"/dir", path!("/dir"),
json!({ json!({
"one.rs": "const ONE: usize = 1;", "one.rs": "const ONE: usize = 1;",
"two.rs": "const TWO: usize = one::ONE + one::ONE;" "two.rs": "const TWO: usize = one::ONE + one::ONE;"
}), }),
) )
.await; .await;
let (project_a, worktree_id) = client_a.build_local_project("/dir", cx_a).await; let (project_a, worktree_id) = client_a.build_local_project(path!("/dir"), cx_a).await;
let project_id = active_call_a let project_id = active_call_a
.update(cx_a, |call, cx| call.share_project(project_a.clone(), cx)) .update(cx_a, |call, cx| call.share_project(project_a.clone(), cx))
.await .await
@ -813,7 +814,10 @@ async fn test_collaborating_with_renames(cx_a: &mut TestAppContext, cx_b: &mut T
fake_language_server fake_language_server
.set_request_handler::<lsp::request::PrepareRenameRequest, _, _>(|params, _| async move { .set_request_handler::<lsp::request::PrepareRenameRequest, _, _>(|params, _| async move {
assert_eq!(params.text_document.uri.as_str(), "file:///dir/one.rs"); assert_eq!(
params.text_document.uri.as_str(),
uri!("file:///dir/one.rs")
);
assert_eq!(params.position, lsp::Position::new(0, 7)); assert_eq!(params.position, lsp::Position::new(0, 7));
Ok(Some(lsp::PrepareRenameResponse::Range(lsp::Range::new( Ok(Some(lsp::PrepareRenameResponse::Range(lsp::Range::new(
lsp::Position::new(0, 6), lsp::Position::new(0, 6),
@ -856,7 +860,10 @@ async fn test_collaborating_with_renames(cx_a: &mut TestAppContext, cx_b: &mut T
fake_language_server fake_language_server
.set_request_handler::<lsp::request::PrepareRenameRequest, _, _>(|params, _| async move { .set_request_handler::<lsp::request::PrepareRenameRequest, _, _>(|params, _| async move {
assert_eq!(params.text_document.uri.as_str(), "file:///dir/one.rs"); assert_eq!(
params.text_document.uri.as_str(),
uri!("file:///dir/one.rs")
);
assert_eq!(params.position, lsp::Position::new(0, 8)); assert_eq!(params.position, lsp::Position::new(0, 8));
Ok(Some(lsp::PrepareRenameResponse::Range(lsp::Range::new( Ok(Some(lsp::PrepareRenameResponse::Range(lsp::Range::new(
lsp::Position::new(0, 6), lsp::Position::new(0, 6),
@ -894,7 +901,7 @@ async fn test_collaborating_with_renames(cx_a: &mut TestAppContext, cx_b: &mut T
.set_request_handler::<lsp::request::Rename, _, _>(|params, _| async move { .set_request_handler::<lsp::request::Rename, _, _>(|params, _| async move {
assert_eq!( assert_eq!(
params.text_document_position.text_document.uri.as_str(), params.text_document_position.text_document.uri.as_str(),
"file:///dir/one.rs" uri!("file:///dir/one.rs")
); );
assert_eq!( assert_eq!(
params.text_document_position.position, params.text_document_position.position,
@ -905,14 +912,14 @@ async fn test_collaborating_with_renames(cx_a: &mut TestAppContext, cx_b: &mut T
changes: Some( changes: Some(
[ [
( (
lsp::Url::from_file_path("/dir/one.rs").unwrap(), lsp::Url::from_file_path(path!("/dir/one.rs")).unwrap(),
vec![lsp::TextEdit::new( vec![lsp::TextEdit::new(
lsp::Range::new(lsp::Position::new(0, 6), lsp::Position::new(0, 9)), lsp::Range::new(lsp::Position::new(0, 6), lsp::Position::new(0, 9)),
"THREE".to_string(), "THREE".to_string(),
)], )],
), ),
( (
lsp::Url::from_file_path("/dir/two.rs").unwrap(), lsp::Url::from_file_path(path!("/dir/two.rs")).unwrap(),
vec![ vec![
lsp::TextEdit::new( lsp::TextEdit::new(
lsp::Range::new( lsp::Range::new(
@ -999,17 +1006,17 @@ async fn test_language_server_statuses(cx_a: &mut TestAppContext, cx_b: &mut Tes
client_a client_a
.fs() .fs()
.insert_tree( .insert_tree(
"/dir", path!("/dir"),
json!({ json!({
"main.rs": "const ONE: usize = 1;", "main.rs": "const ONE: usize = 1;",
}), }),
) )
.await; .await;
let (project_a, _) = client_a.build_local_project("/dir", cx_a).await; let (project_a, _) = client_a.build_local_project(path!("/dir"), cx_a).await;
let _buffer_a = project_a let _buffer_a = project_a
.update(cx_a, |p, cx| { .update(cx_a, |p, cx| {
p.open_local_buffer_with_lsp("/dir/main.rs", cx) p.open_local_buffer_with_lsp(path!("/dir/main.rs"), cx)
}) })
.await .await
.unwrap(); .unwrap();
@ -1106,7 +1113,7 @@ async fn test_share_project(
client_a client_a
.fs() .fs()
.insert_tree( .insert_tree(
"/a", path!("/a"),
json!({ json!({
".gitignore": "ignored-dir", ".gitignore": "ignored-dir",
"a.txt": "a-contents", "a.txt": "a-contents",
@ -1120,7 +1127,7 @@ async fn test_share_project(
.await; .await;
// Invite client B to collaborate on a project // Invite client B to collaborate on a project
let (project_a, worktree_id) = client_a.build_local_project("/a", cx_a).await; let (project_a, worktree_id) = client_a.build_local_project(path!("/a"), cx_a).await;
active_call_a active_call_a
.update(cx_a, |call, cx| { .update(cx_a, |call, cx| {
call.invite(client_b.user_id().unwrap(), Some(project_a.clone()), cx) call.invite(client_b.user_id().unwrap(), Some(project_a.clone()), cx)
@ -1292,14 +1299,14 @@ async fn test_on_input_format_from_host_to_guest(
client_a client_a
.fs() .fs()
.insert_tree( .insert_tree(
"/a", path!("/a"),
json!({ json!({
"main.rs": "fn main() { a }", "main.rs": "fn main() { a }",
"other.rs": "// Test file", "other.rs": "// Test file",
}), }),
) )
.await; .await;
let (project_a, worktree_id) = client_a.build_local_project("/a", cx_a).await; let (project_a, worktree_id) = client_a.build_local_project(path!("/a"), cx_a).await;
let project_id = active_call_a let project_id = active_call_a
.update(cx_a, |call, cx| call.share_project(project_a.clone(), cx)) .update(cx_a, |call, cx| call.share_project(project_a.clone(), cx))
.await .await
@ -1325,7 +1332,7 @@ async fn test_on_input_format_from_host_to_guest(
|params, _| async move { |params, _| async move {
assert_eq!( assert_eq!(
params.text_document_position.text_document.uri, params.text_document_position.text_document.uri,
lsp::Url::from_file_path("/a/main.rs").unwrap(), lsp::Url::from_file_path(path!("/a/main.rs")).unwrap(),
); );
assert_eq!( assert_eq!(
params.text_document_position.position, params.text_document_position.position,
@ -1414,14 +1421,14 @@ async fn test_on_input_format_from_guest_to_host(
client_a client_a
.fs() .fs()
.insert_tree( .insert_tree(
"/a", path!("/a"),
json!({ json!({
"main.rs": "fn main() { a }", "main.rs": "fn main() { a }",
"other.rs": "// Test file", "other.rs": "// Test file",
}), }),
) )
.await; .await;
let (project_a, worktree_id) = client_a.build_local_project("/a", cx_a).await; let (project_a, worktree_id) = client_a.build_local_project(path!("/a"), cx_a).await;
let project_id = active_call_a let project_id = active_call_a
.update(cx_a, |call, cx| call.share_project(project_a.clone(), cx)) .update(cx_a, |call, cx| call.share_project(project_a.clone(), cx))
.await .await
@ -1455,7 +1462,7 @@ async fn test_on_input_format_from_guest_to_host(
.set_request_handler::<lsp::request::OnTypeFormatting, _, _>(|params, _| async move { .set_request_handler::<lsp::request::OnTypeFormatting, _, _>(|params, _| async move {
assert_eq!( assert_eq!(
params.text_document_position.text_document.uri, params.text_document_position.text_document.uri,
lsp::Url::from_file_path("/a/main.rs").unwrap(), lsp::Url::from_file_path(path!("/a/main.rs")).unwrap(),
); );
assert_eq!( assert_eq!(
params.text_document_position.position, params.text_document_position.position,
@ -1575,14 +1582,14 @@ async fn test_mutual_editor_inlay_hint_cache_update(
client_a client_a
.fs() .fs()
.insert_tree( .insert_tree(
"/a", path!("/a"),
json!({ json!({
"main.rs": "fn main() { a } // and some long comment to ensure inlay hints are not trimmed out", "main.rs": "fn main() { a } // and some long comment to ensure inlay hints are not trimmed out",
"other.rs": "// Test file", "other.rs": "// Test file",
}), }),
) )
.await; .await;
let (project_a, worktree_id) = client_a.build_local_project("/a", cx_a).await; let (project_a, worktree_id) = client_a.build_local_project(path!("/a"), cx_a).await;
active_call_a active_call_a
.update(cx_a, |call, cx| call.set_location(Some(&project_a), cx)) .update(cx_a, |call, cx| call.set_location(Some(&project_a), cx))
.await .await
@ -1605,7 +1612,7 @@ async fn test_mutual_editor_inlay_hint_cache_update(
// The host opens a rust file. // The host opens a rust file.
let _buffer_a = project_a let _buffer_a = project_a
.update(cx_a, |project, cx| { .update(cx_a, |project, cx| {
project.open_local_buffer("/a/main.rs", cx) project.open_local_buffer(path!("/a/main.rs"), cx)
}) })
.await .await
.unwrap(); .unwrap();
@ -1629,7 +1636,7 @@ async fn test_mutual_editor_inlay_hint_cache_update(
async move { async move {
assert_eq!( assert_eq!(
params.text_document.uri, params.text_document.uri,
lsp::Url::from_file_path("/a/main.rs").unwrap(), lsp::Url::from_file_path(path!("/a/main.rs")).unwrap(),
); );
let edits_made = task_edits_made.load(atomic::Ordering::Acquire); let edits_made = task_edits_made.load(atomic::Ordering::Acquire);
Ok(Some(vec![lsp::InlayHint { Ok(Some(vec![lsp::InlayHint {
@ -1809,14 +1816,14 @@ async fn test_inlay_hint_refresh_is_forwarded(
client_a client_a
.fs() .fs()
.insert_tree( .insert_tree(
"/a", path!("/a"),
json!({ json!({
"main.rs": "fn main() { a } // and some long comment to ensure inlay hints are not trimmed out", "main.rs": "fn main() { a } // and some long comment to ensure inlay hints are not trimmed out",
"other.rs": "// Test file", "other.rs": "// Test file",
}), }),
) )
.await; .await;
let (project_a, worktree_id) = client_a.build_local_project("/a", cx_a).await; let (project_a, worktree_id) = client_a.build_local_project(path!("/a"), cx_a).await;
active_call_a active_call_a
.update(cx_a, |call, cx| call.set_location(Some(&project_a), cx)) .update(cx_a, |call, cx| call.set_location(Some(&project_a), cx))
.await .await
@ -1864,7 +1871,7 @@ async fn test_inlay_hint_refresh_is_forwarded(
async move { async move {
assert_eq!( assert_eq!(
params.text_document.uri, params.text_document.uri,
lsp::Url::from_file_path("/a/main.rs").unwrap(), lsp::Url::from_file_path(path!("/a/main.rs")).unwrap(),
); );
let other_hints = task_other_hints.load(atomic::Ordering::Acquire); let other_hints = task_other_hints.load(atomic::Ordering::Acquire);
let character = if other_hints { 0 } else { 2 }; let character = if other_hints { 0 } else { 2 };
@ -1967,7 +1974,7 @@ async fn test_git_blame_is_forwarded(cx_a: &mut TestAppContext, cx_b: &mut TestA
client_a client_a
.fs() .fs()
.insert_tree( .insert_tree(
"/my-repo", path!("/my-repo"),
json!({ json!({
".git": {}, ".git": {},
"file.txt": "line1\nline2\nline3\nline\n", "file.txt": "line1\nline2\nline3\nline\n",
@ -1993,11 +2000,12 @@ async fn test_git_blame_is_forwarded(cx_a: &mut TestAppContext, cx_b: &mut TestA
.collect(), .collect(),
remote_url: Some("git@github.com:zed-industries/zed.git".to_string()), remote_url: Some("git@github.com:zed-industries/zed.git".to_string()),
}; };
client_a client_a.fs().set_blame_for_repo(
.fs() Path::new(path!("/my-repo/.git")),
.set_blame_for_repo(Path::new("/my-repo/.git"), vec![("file.txt".into(), blame)]); vec![("file.txt".into(), blame)],
);
let (project_a, worktree_id) = client_a.build_local_project("/my-repo", cx_a).await; let (project_a, worktree_id) = client_a.build_local_project(path!("/my-repo"), cx_a).await;
let project_id = active_call_a let project_id = active_call_a
.update(cx_a, |call, cx| call.share_project(project_a.clone(), cx)) .update(cx_a, |call, cx| call.share_project(project_a.clone(), cx))
.await .await
@ -2177,7 +2185,7 @@ async fn test_collaborating_with_editorconfig(
client_a client_a
.fs() .fs()
.insert_tree( .insert_tree(
"/a", path!("/a"),
json!({ json!({
"src": { "src": {
"main.rs": "mod other;\nfn main() { let foo = other::foo(); }", "main.rs": "mod other;\nfn main() { let foo = other::foo(); }",
@ -2190,7 +2198,7 @@ async fn test_collaborating_with_editorconfig(
}), }),
) )
.await; .await;
let (project_a, worktree_id) = client_a.build_local_project("/a", cx_a).await; let (project_a, worktree_id) = client_a.build_local_project(path!("/a"), cx_a).await;
let project_id = active_call_a let project_id = active_call_a
.update(cx_a, |call, cx| call.share_project(project_a.clone(), cx)) .update(cx_a, |call, cx| call.share_project(project_a.clone(), cx))
.await .await
@ -2309,7 +2317,7 @@ fn main() { let foo = other::foo(); }"};
client_a client_a
.fs() .fs()
.atomic_write( .atomic_write(
PathBuf::from("/a/src/.editorconfig"), PathBuf::from(path!("/a/src/.editorconfig")),
"[*]\ntab_width = 3\n".to_owned(), "[*]\ntab_width = 3\n".to_owned(),
) )
.await .await

View file

@ -16,6 +16,7 @@ use project::WorktreeSettings;
use rpc::proto::PeerId; use rpc::proto::PeerId;
use serde_json::json; use serde_json::json;
use settings::SettingsStore; use settings::SettingsStore;
use util::path;
use workspace::{item::ItemHandle as _, SplitDirection, Workspace}; use workspace::{item::ItemHandle as _, SplitDirection, Workspace};
use super::TestClient; use super::TestClient;
@ -50,7 +51,7 @@ async fn test_basic_following(
client_a client_a
.fs() .fs()
.insert_tree( .insert_tree(
"/a", path!("/a"),
json!({ json!({
"1.txt": "one\none\none", "1.txt": "one\none\none",
"2.txt": "two\ntwo\ntwo", "2.txt": "two\ntwo\ntwo",
@ -58,7 +59,7 @@ async fn test_basic_following(
}), }),
) )
.await; .await;
let (project_a, worktree_id) = client_a.build_local_project("/a", cx_a).await; let (project_a, worktree_id) = client_a.build_local_project(path!("/a"), cx_a).await;
active_call_a active_call_a
.update(cx_a, |call, cx| call.set_location(Some(&project_a), cx)) .update(cx_a, |call, cx| call.set_location(Some(&project_a), cx))
.await .await
@ -436,7 +437,9 @@ async fn test_basic_following(
); );
// TODO: Re-enable this test once we can replace our swift Livekit SDK with the rust SDK // TODO: Re-enable this test once we can replace our swift Livekit SDK with the rust SDK
#[cfg(not(target_os = "macos"))] // todo(windows)
// Fix this on Windows
#[cfg(all(not(target_os = "macos"), not(target_os = "windows")))]
{ {
use crate::rpc::RECONNECT_TIMEOUT; use crate::rpc::RECONNECT_TIMEOUT;
use gpui::TestScreenCaptureSource; use gpui::TestScreenCaptureSource;
@ -1220,7 +1223,7 @@ async fn test_auto_unfollowing(cx_a: &mut TestAppContext, cx_b: &mut TestAppCont
client_a client_a
.fs() .fs()
.insert_tree( .insert_tree(
"/a", path!("/a"),
json!({ json!({
"1.txt": "one", "1.txt": "one",
"2.txt": "two", "2.txt": "two",
@ -1228,7 +1231,7 @@ async fn test_auto_unfollowing(cx_a: &mut TestAppContext, cx_b: &mut TestAppCont
}), }),
) )
.await; .await;
let (project_a, worktree_id) = client_a.build_local_project("/a", cx_a).await; let (project_a, worktree_id) = client_a.build_local_project(path!("/a"), cx_a).await;
active_call_a active_call_a
.update(cx_a, |call, cx| call.set_location(Some(&project_a), cx)) .update(cx_a, |call, cx| call.set_location(Some(&project_a), cx))
.await .await
@ -1435,7 +1438,7 @@ async fn test_following_across_workspaces(cx_a: &mut TestAppContext, cx_b: &mut
client_a client_a
.fs() .fs()
.insert_tree( .insert_tree(
"/a", path!("/a"),
json!({ json!({
"w.rs": "", "w.rs": "",
"x.rs": "", "x.rs": "",
@ -1446,7 +1449,7 @@ async fn test_following_across_workspaces(cx_a: &mut TestAppContext, cx_b: &mut
client_b client_b
.fs() .fs()
.insert_tree( .insert_tree(
"/b", path!("/b"),
json!({ json!({
"y.rs": "", "y.rs": "",
"z.rs": "", "z.rs": "",
@ -1460,8 +1463,8 @@ async fn test_following_across_workspaces(cx_a: &mut TestAppContext, cx_b: &mut
let active_call_a = cx_a.read(ActiveCall::global); let active_call_a = cx_a.read(ActiveCall::global);
let active_call_b = cx_b.read(ActiveCall::global); let active_call_b = cx_b.read(ActiveCall::global);
let (project_a, worktree_id_a) = client_a.build_local_project("/a", cx_a).await; let (project_a, worktree_id_a) = client_a.build_local_project(path!("/a"), cx_a).await;
let (project_b, worktree_id_b) = client_b.build_local_project("/b", cx_b).await; let (project_b, worktree_id_b) = client_b.build_local_project(path!("/b"), cx_b).await;
let (workspace_a, cx_a) = client_a.build_workspace(&project_a, cx_a); let (workspace_a, cx_a) = client_a.build_workspace(&project_a, cx_a);
let (workspace_b, cx_b) = client_b.build_workspace(&project_b, cx_b); let (workspace_b, cx_b) = client_b.build_workspace(&project_b, cx_b);
@ -1718,7 +1721,7 @@ async fn test_following_into_excluded_file(
client_a client_a
.fs() .fs()
.insert_tree( .insert_tree(
"/a", path!("/a"),
json!({ json!({
".git": { ".git": {
"COMMIT_EDITMSG": "write your commit message here", "COMMIT_EDITMSG": "write your commit message here",
@ -1729,7 +1732,7 @@ async fn test_following_into_excluded_file(
}), }),
) )
.await; .await;
let (project_a, worktree_id) = client_a.build_local_project("/a", cx_a).await; let (project_a, worktree_id) = client_a.build_local_project(path!("/a"), cx_a).await;
active_call_a active_call_a
.update(cx_a, |call, cx| call.set_location(Some(&project_a), cx)) .update(cx_a, |call, cx| call.set_location(Some(&project_a), cx))
.await .await

View file

@ -9,6 +9,7 @@ use git_ui::project_diff::ProjectDiff;
use gpui::{TestAppContext, VisualTestContext}; use gpui::{TestAppContext, VisualTestContext};
use project::ProjectPath; use project::ProjectPath;
use serde_json::json; use serde_json::json;
use util::path;
use workspace::Workspace; use workspace::Workspace;
// //
@ -29,7 +30,7 @@ async fn test_project_diff(cx_a: &mut TestAppContext, cx_b: &mut TestAppContext)
client_a client_a
.fs() .fs()
.insert_tree( .insert_tree(
"/a", path!("/a"),
json!({ json!({
".git": {}, ".git": {},
"changed.txt": "after\n", "changed.txt": "after\n",
@ -41,7 +42,7 @@ async fn test_project_diff(cx_a: &mut TestAppContext, cx_b: &mut TestAppContext)
.await; .await;
client_a.fs().set_git_content_for_repo( client_a.fs().set_git_content_for_repo(
Path::new("/a/.git"), Path::new(path!("/a/.git")),
&[ &[
("changed.txt".into(), "before\n".to_string(), None), ("changed.txt".into(), "before\n".to_string(), None),
("unchanged.txt".into(), "unchanged\n".to_string(), None), ("unchanged.txt".into(), "unchanged\n".to_string(), None),
@ -49,7 +50,7 @@ async fn test_project_diff(cx_a: &mut TestAppContext, cx_b: &mut TestAppContext)
("secret.pem".into(), "shh\n".to_string(), None), ("secret.pem".into(), "shh\n".to_string(), None),
], ],
); );
let (project_a, worktree_id) = client_a.build_local_project("/a", cx_a).await; let (project_a, worktree_id) = client_a.build_local_project(path!("/a"), cx_a).await;
let active_call_a = cx_a.read(ActiveCall::global); let active_call_a = cx_a.read(ActiveCall::global);
let project_id = active_call_a let project_id = active_call_a
.update(cx_a, |call, cx| call.share_project(project_a.clone(), cx)) .update(cx_a, |call, cx| call.share_project(project_a.clone(), cx))
@ -93,7 +94,7 @@ async fn test_project_diff(cx_a: &mut TestAppContext, cx_b: &mut TestAppContext)
client_a client_a
.fs() .fs()
.insert_tree( .insert_tree(
"/a", path!("/a"),
json!({ json!({
".git": {}, ".git": {},
"changed.txt": "before\n", "changed.txt": "before\n",

View file

@ -50,6 +50,7 @@ use std::{
time::Duration, time::Duration,
}; };
use unindent::Unindent as _; use unindent::Unindent as _;
use util::{path, separator, uri};
use workspace::Pane; use workspace::Pane;
#[ctor::ctor] #[ctor::ctor]
@ -1459,7 +1460,7 @@ async fn test_project_reconnect(
client_a client_a
.fs() .fs()
.insert_tree( .insert_tree(
"/root-1", path!("/root-1"),
json!({ json!({
"dir1": { "dir1": {
"a.txt": "a", "a.txt": "a",
@ -1487,7 +1488,7 @@ async fn test_project_reconnect(
client_a client_a
.fs() .fs()
.insert_tree( .insert_tree(
"/root-2", path!("/root-2"),
json!({ json!({
"2.txt": "2", "2.txt": "2",
}), }),
@ -1496,7 +1497,7 @@ async fn test_project_reconnect(
client_a client_a
.fs() .fs()
.insert_tree( .insert_tree(
"/root-3", path!("/root-3"),
json!({ json!({
"3.txt": "3", "3.txt": "3",
}), }),
@ -1504,9 +1505,11 @@ async fn test_project_reconnect(
.await; .await;
let active_call_a = cx_a.read(ActiveCall::global); let active_call_a = cx_a.read(ActiveCall::global);
let (project_a1, _) = client_a.build_local_project("/root-1/dir1", cx_a).await; let (project_a1, _) = client_a
let (project_a2, _) = client_a.build_local_project("/root-2", cx_a).await; .build_local_project(path!("/root-1/dir1"), cx_a)
let (project_a3, _) = client_a.build_local_project("/root-3", cx_a).await; .await;
let (project_a2, _) = client_a.build_local_project(path!("/root-2"), cx_a).await;
let (project_a3, _) = client_a.build_local_project(path!("/root-3"), cx_a).await;
let worktree_a1 = let worktree_a1 =
project_a1.read_with(cx_a, |project, cx| project.worktrees(cx).next().unwrap()); project_a1.read_with(cx_a, |project, cx| project.worktrees(cx).next().unwrap());
let project1_id = active_call_a let project1_id = active_call_a
@ -1533,7 +1536,7 @@ async fn test_project_reconnect(
}); });
let (worktree_a2, _) = project_a1 let (worktree_a2, _) = project_a1
.update(cx_a, |p, cx| { .update(cx_a, |p, cx| {
p.find_or_create_worktree("/root-1/dir2", true, cx) p.find_or_create_worktree(path!("/root-1/dir2"), true, cx)
}) })
.await .await
.unwrap(); .unwrap();
@ -1579,7 +1582,7 @@ async fn test_project_reconnect(
client_a client_a
.fs() .fs()
.insert_tree( .insert_tree(
"/root-1/dir1/subdir2", path!("/root-1/dir1/subdir2"),
json!({ json!({
"f.txt": "f-contents", "f.txt": "f-contents",
"g.txt": "g-contents", "g.txt": "g-contents",
@ -1591,7 +1594,7 @@ async fn test_project_reconnect(
client_a client_a
.fs() .fs()
.remove_dir( .remove_dir(
"/root-1/dir1/subdir1".as_ref(), path!("/root-1/dir1/subdir1").as_ref(),
RemoveOptions { RemoveOptions {
recursive: true, recursive: true,
..Default::default() ..Default::default()
@ -1606,7 +1609,7 @@ async fn test_project_reconnect(
}); });
let (worktree_a3, _) = project_a1 let (worktree_a3, _) = project_a1
.update(cx_a, |p, cx| { .update(cx_a, |p, cx| {
p.find_or_create_worktree("/root-1/dir3", true, cx) p.find_or_create_worktree(path!("/root-1/dir3"), true, cx)
}) })
.await .await
.unwrap(); .unwrap();
@ -1647,13 +1650,13 @@ async fn test_project_reconnect(
.map(|p| p.to_str().unwrap()) .map(|p| p.to_str().unwrap())
.collect::<Vec<_>>(), .collect::<Vec<_>>(),
vec![ vec![
"a.txt", separator!("a.txt"),
"b.txt", separator!("b.txt"),
"subdir2", separator!("subdir2"),
"subdir2/f.txt", separator!("subdir2/f.txt"),
"subdir2/g.txt", separator!("subdir2/g.txt"),
"subdir2/h.txt", separator!("subdir2/h.txt"),
"subdir2/i.txt" separator!("subdir2/i.txt")
] ]
); );
assert!(worktree_a3.read(cx).has_update_observer()); assert!(worktree_a3.read(cx).has_update_observer());
@ -1680,13 +1683,13 @@ async fn test_project_reconnect(
.map(|p| p.to_str().unwrap()) .map(|p| p.to_str().unwrap())
.collect::<Vec<_>>(), .collect::<Vec<_>>(),
vec![ vec![
"a.txt", separator!("a.txt"),
"b.txt", separator!("b.txt"),
"subdir2", separator!("subdir2"),
"subdir2/f.txt", separator!("subdir2/f.txt"),
"subdir2/g.txt", separator!("subdir2/g.txt"),
"subdir2/h.txt", separator!("subdir2/h.txt"),
"subdir2/i.txt" separator!("subdir2/i.txt")
] ]
); );
assert!(project.worktree_for_id(worktree2_id, cx).is_none()); assert!(project.worktree_for_id(worktree2_id, cx).is_none());
@ -1719,18 +1722,21 @@ async fn test_project_reconnect(
// While client B is disconnected, add and remove files from client A's project // While client B is disconnected, add and remove files from client A's project
client_a client_a
.fs() .fs()
.insert_file("/root-1/dir1/subdir2/j.txt", "j-contents".into()) .insert_file(path!("/root-1/dir1/subdir2/j.txt"), "j-contents".into())
.await; .await;
client_a client_a
.fs() .fs()
.remove_file("/root-1/dir1/subdir2/i.txt".as_ref(), Default::default()) .remove_file(
path!("/root-1/dir1/subdir2/i.txt").as_ref(),
Default::default(),
)
.await .await
.unwrap(); .unwrap();
// While client B is disconnected, add and remove worktrees from client A's project. // While client B is disconnected, add and remove worktrees from client A's project.
let (worktree_a4, _) = project_a1 let (worktree_a4, _) = project_a1
.update(cx_a, |p, cx| { .update(cx_a, |p, cx| {
p.find_or_create_worktree("/root-1/dir4", true, cx) p.find_or_create_worktree(path!("/root-1/dir4"), true, cx)
}) })
.await .await
.unwrap(); .unwrap();
@ -1773,13 +1779,13 @@ async fn test_project_reconnect(
.map(|p| p.to_str().unwrap()) .map(|p| p.to_str().unwrap())
.collect::<Vec<_>>(), .collect::<Vec<_>>(),
vec![ vec![
"a.txt", separator!("a.txt"),
"b.txt", separator!("b.txt"),
"subdir2", separator!("subdir2"),
"subdir2/f.txt", separator!("subdir2/f.txt"),
"subdir2/g.txt", separator!("subdir2/g.txt"),
"subdir2/h.txt", separator!("subdir2/h.txt"),
"subdir2/j.txt" separator!("subdir2/j.txt")
] ]
); );
assert!(project.worktree_for_id(worktree2_id, cx).is_none()); assert!(project.worktree_for_id(worktree2_id, cx).is_none());
@ -2316,14 +2322,14 @@ async fn test_propagate_saves_and_fs_changes(
client_a client_a
.fs() .fs()
.insert_tree( .insert_tree(
"/a", path!("/a"),
json!({ json!({
"file1.rs": "", "file1.rs": "",
"file2": "" "file2": ""
}), }),
) )
.await; .await;
let (project_a, worktree_id) = client_a.build_local_project("/a", cx_a).await; let (project_a, worktree_id) = client_a.build_local_project(path!("/a"), cx_a).await;
let worktree_a = project_a.read_with(cx_a, |p, cx| p.worktrees(cx).next().unwrap()); let worktree_a = project_a.read_with(cx_a, |p, cx| p.worktrees(cx).next().unwrap());
let project_id = active_call_a let project_id = active_call_a
@ -2409,18 +2415,25 @@ async fn test_propagate_saves_and_fs_changes(
client_a client_a
.fs() .fs()
.rename( .rename(
"/a/file1.rs".as_ref(), path!("/a/file1.rs").as_ref(),
"/a/file1.js".as_ref(), path!("/a/file1.js").as_ref(),
Default::default(), Default::default(),
) )
.await .await
.unwrap(); .unwrap();
client_a client_a
.fs() .fs()
.rename("/a/file2".as_ref(), "/a/file3".as_ref(), Default::default()) .rename(
path!("/a/file2").as_ref(),
path!("/a/file3").as_ref(),
Default::default(),
)
.await .await
.unwrap(); .unwrap();
client_a.fs().insert_file("/a/file4", "4".into()).await; client_a
.fs()
.insert_file(path!("/a/file4"), "4".into())
.await;
executor.run_until_parked(); executor.run_until_parked();
worktree_a.read_with(cx_a, |tree, _| { worktree_a.read_with(cx_a, |tree, _| {
@ -2959,7 +2972,7 @@ async fn test_git_status_sync(
client_a client_a
.fs() .fs()
.insert_tree( .insert_tree(
"/dir", path!("/dir"),
json!({ json!({
".git": {}, ".git": {},
"a.txt": "a", "a.txt": "a",
@ -2972,11 +2985,11 @@ async fn test_git_status_sync(
// Initially, a.txt is uncommitted, but present in the index, // Initially, a.txt is uncommitted, but present in the index,
// and b.txt is unmerged. // and b.txt is unmerged.
client_a.fs().set_head_for_repo( client_a.fs().set_head_for_repo(
"/dir/.git".as_ref(), path!("/dir/.git").as_ref(),
&[("b.txt".into(), "B".into()), ("c.txt".into(), "c".into())], &[("b.txt".into(), "B".into()), ("c.txt".into(), "c".into())],
); );
client_a.fs().set_index_for_repo( client_a.fs().set_index_for_repo(
"/dir/.git".as_ref(), path!("/dir/.git").as_ref(),
&[ &[
("a.txt".into(), "".into()), ("a.txt".into(), "".into()),
("b.txt".into(), "B".into()), ("b.txt".into(), "B".into()),
@ -2984,7 +2997,7 @@ async fn test_git_status_sync(
], ],
); );
client_a.fs().set_unmerged_paths_for_repo( client_a.fs().set_unmerged_paths_for_repo(
"/dir/.git".as_ref(), path!("/dir/.git").as_ref(),
&[( &[(
"b.txt".into(), "b.txt".into(),
UnmergedStatus { UnmergedStatus {
@ -3003,7 +3016,7 @@ async fn test_git_status_sync(
second_head: UnmergedStatusCode::Deleted, second_head: UnmergedStatusCode::Deleted,
}); });
let (project_local, _worktree_id) = client_a.build_local_project("/dir", cx_a).await; let (project_local, _worktree_id) = client_a.build_local_project(path!("/dir"), cx_a).await;
let project_id = active_call_a let project_id = active_call_a
.update(cx_a, |call, cx| { .update(cx_a, |call, cx| {
call.share_project(project_local.clone(), cx) call.share_project(project_local.clone(), cx)
@ -3068,15 +3081,15 @@ async fn test_git_status_sync(
// Delete b.txt from the index, mark conflict as resolved, // Delete b.txt from the index, mark conflict as resolved,
// and modify c.txt in the working copy. // and modify c.txt in the working copy.
client_a.fs().set_index_for_repo( client_a.fs().set_index_for_repo(
"/dir/.git".as_ref(), path!("/dir/.git").as_ref(),
&[("a.txt".into(), "a".into()), ("c.txt".into(), "c".into())], &[("a.txt".into(), "a".into()), ("c.txt".into(), "c".into())],
); );
client_a client_a
.fs() .fs()
.set_unmerged_paths_for_repo("/dir/.git".as_ref(), &[]); .set_unmerged_paths_for_repo(path!("/dir/.git").as_ref(), &[]);
client_a client_a
.fs() .fs()
.atomic_write("/dir/c.txt".into(), "CC".into()) .atomic_write(path!("/dir/c.txt").into(), "CC".into())
.await .await
.unwrap(); .unwrap();
@ -3109,7 +3122,7 @@ async fn test_git_status_sync(
// Now remove the original git repository and check that collaborators are notified. // Now remove the original git repository and check that collaborators are notified.
client_a client_a
.fs() .fs()
.remove_dir("/dir/.git".as_ref(), RemoveOptions::default()) .remove_dir(path!("/dir/.git").as_ref(), RemoveOptions::default())
.await .await
.unwrap(); .unwrap();
@ -3145,14 +3158,14 @@ async fn test_fs_operations(
client_a client_a
.fs() .fs()
.insert_tree( .insert_tree(
"/dir", path!("/dir"),
json!({ json!({
"a.txt": "a-contents", "a.txt": "a-contents",
"b.txt": "b-contents", "b.txt": "b-contents",
}), }),
) )
.await; .await;
let (project_a, worktree_id) = client_a.build_local_project("/dir", cx_a).await; let (project_a, worktree_id) = client_a.build_local_project(path!("/dir"), cx_a).await;
let project_id = active_call_a let project_id = active_call_a
.update(cx_a, |call, cx| call.share_project(project_a.clone(), cx)) .update(cx_a, |call, cx| call.share_project(project_a.clone(), cx))
.await .await
@ -3283,13 +3296,13 @@ async fn test_fs_operations(
.map(|p| p.to_string_lossy()) .map(|p| p.to_string_lossy())
.collect::<Vec<_>>(), .collect::<Vec<_>>(),
[ [
"DIR", separator!("DIR"),
"DIR/SUBDIR", separator!("DIR/SUBDIR"),
"DIR/SUBDIR/f.txt", separator!("DIR/SUBDIR/f.txt"),
"DIR/e.txt", separator!("DIR/e.txt"),
"a.txt", separator!("a.txt"),
"b.txt", separator!("b.txt"),
"d.txt" separator!("d.txt")
] ]
); );
}); });
@ -3301,13 +3314,13 @@ async fn test_fs_operations(
.map(|p| p.to_string_lossy()) .map(|p| p.to_string_lossy())
.collect::<Vec<_>>(), .collect::<Vec<_>>(),
[ [
"DIR", separator!("DIR"),
"DIR/SUBDIR", separator!("DIR/SUBDIR"),
"DIR/SUBDIR/f.txt", separator!("DIR/SUBDIR/f.txt"),
"DIR/e.txt", separator!("DIR/e.txt"),
"a.txt", separator!("a.txt"),
"b.txt", separator!("b.txt"),
"d.txt" separator!("d.txt")
] ]
); );
}); });
@ -3327,14 +3340,14 @@ async fn test_fs_operations(
.map(|p| p.to_string_lossy()) .map(|p| p.to_string_lossy())
.collect::<Vec<_>>(), .collect::<Vec<_>>(),
[ [
"DIR", separator!("DIR"),
"DIR/SUBDIR", separator!("DIR/SUBDIR"),
"DIR/SUBDIR/f.txt", separator!("DIR/SUBDIR/f.txt"),
"DIR/e.txt", separator!("DIR/e.txt"),
"a.txt", separator!("a.txt"),
"b.txt", separator!("b.txt"),
"d.txt", separator!("d.txt"),
"f.txt" separator!("f.txt")
] ]
); );
}); });
@ -3346,14 +3359,14 @@ async fn test_fs_operations(
.map(|p| p.to_string_lossy()) .map(|p| p.to_string_lossy())
.collect::<Vec<_>>(), .collect::<Vec<_>>(),
[ [
"DIR", separator!("DIR"),
"DIR/SUBDIR", separator!("DIR/SUBDIR"),
"DIR/SUBDIR/f.txt", separator!("DIR/SUBDIR/f.txt"),
"DIR/e.txt", separator!("DIR/e.txt"),
"a.txt", separator!("a.txt"),
"b.txt", separator!("b.txt"),
"d.txt", separator!("d.txt"),
"f.txt" separator!("f.txt")
] ]
); );
}); });
@ -3570,13 +3583,13 @@ async fn test_buffer_conflict_after_save(
client_a client_a
.fs() .fs()
.insert_tree( .insert_tree(
"/dir", path!("/dir"),
json!({ json!({
"a.txt": "a-contents", "a.txt": "a-contents",
}), }),
) )
.await; .await;
let (project_a, worktree_id) = client_a.build_local_project("/dir", cx_a).await; let (project_a, worktree_id) = client_a.build_local_project(path!("/dir"), cx_a).await;
let project_id = active_call_a let project_id = active_call_a
.update(cx_a, |call, cx| call.share_project(project_a.clone(), cx)) .update(cx_a, |call, cx| call.share_project(project_a.clone(), cx))
.await .await
@ -3634,13 +3647,13 @@ async fn test_buffer_reloading(
client_a client_a
.fs() .fs()
.insert_tree( .insert_tree(
"/dir", path!("/dir"),
json!({ json!({
"a.txt": "a\nb\nc", "a.txt": "a\nb\nc",
}), }),
) )
.await; .await;
let (project_a, worktree_id) = client_a.build_local_project("/dir", cx_a).await; let (project_a, worktree_id) = client_a.build_local_project(path!("/dir"), cx_a).await;
let project_id = active_call_a let project_id = active_call_a
.update(cx_a, |call, cx| call.share_project(project_a.clone(), cx)) .update(cx_a, |call, cx| call.share_project(project_a.clone(), cx))
.await .await
@ -3662,7 +3675,11 @@ async fn test_buffer_reloading(
let new_contents = Rope::from("d\ne\nf"); let new_contents = Rope::from("d\ne\nf");
client_a client_a
.fs() .fs()
.save("/dir/a.txt".as_ref(), &new_contents, LineEnding::Windows) .save(
path!("/dir/a.txt").as_ref(),
&new_contents,
LineEnding::Windows,
)
.await .await
.unwrap(); .unwrap();
@ -3692,9 +3709,9 @@ async fn test_editing_while_guest_opens_buffer(
client_a client_a
.fs() .fs()
.insert_tree("/dir", json!({ "a.txt": "a-contents" })) .insert_tree(path!("/dir"), json!({ "a.txt": "a-contents" }))
.await; .await;
let (project_a, worktree_id) = client_a.build_local_project("/dir", cx_a).await; let (project_a, worktree_id) = client_a.build_local_project(path!("/dir"), cx_a).await;
let project_id = active_call_a let project_id = active_call_a
.update(cx_a, |call, cx| call.share_project(project_a.clone(), cx)) .update(cx_a, |call, cx| call.share_project(project_a.clone(), cx))
.await .await
@ -4007,19 +4024,19 @@ async fn test_collaborating_with_diagnostics(
client_a client_a
.fs() .fs()
.insert_tree( .insert_tree(
"/a", path!("/a"),
json!({ json!({
"a.rs": "let one = two", "a.rs": "let one = two",
"other.rs": "", "other.rs": "",
}), }),
) )
.await; .await;
let (project_a, worktree_id) = client_a.build_local_project("/a", cx_a).await; let (project_a, worktree_id) = client_a.build_local_project(path!("/a"), cx_a).await;
// Cause the language server to start. // Cause the language server to start.
let _buffer = project_a let _buffer = project_a
.update(cx_a, |project, cx| { .update(cx_a, |project, cx| {
project.open_local_buffer_with_lsp("/a/other.rs", cx) project.open_local_buffer_with_lsp(path!("/a/other.rs"), cx)
}) })
.await .await
.unwrap(); .unwrap();
@ -4031,7 +4048,7 @@ async fn test_collaborating_with_diagnostics(
.await; .await;
fake_language_server.notify::<lsp::notification::PublishDiagnostics>( fake_language_server.notify::<lsp::notification::PublishDiagnostics>(
&lsp::PublishDiagnosticsParams { &lsp::PublishDiagnosticsParams {
uri: lsp::Url::from_file_path("/a/a.rs").unwrap(), uri: lsp::Url::from_file_path(path!("/a/a.rs")).unwrap(),
version: None, version: None,
diagnostics: vec![lsp::Diagnostic { diagnostics: vec![lsp::Diagnostic {
severity: Some(lsp::DiagnosticSeverity::WARNING), severity: Some(lsp::DiagnosticSeverity::WARNING),
@ -4051,7 +4068,7 @@ async fn test_collaborating_with_diagnostics(
.unwrap(); .unwrap();
fake_language_server.notify::<lsp::notification::PublishDiagnostics>( fake_language_server.notify::<lsp::notification::PublishDiagnostics>(
&lsp::PublishDiagnosticsParams { &lsp::PublishDiagnosticsParams {
uri: lsp::Url::from_file_path("/a/a.rs").unwrap(), uri: lsp::Url::from_file_path(path!("/a/a.rs")).unwrap(),
version: None, version: None,
diagnostics: vec![lsp::Diagnostic { diagnostics: vec![lsp::Diagnostic {
severity: Some(lsp::DiagnosticSeverity::ERROR), severity: Some(lsp::DiagnosticSeverity::ERROR),
@ -4125,7 +4142,7 @@ async fn test_collaborating_with_diagnostics(
// Simulate a language server reporting more errors for a file. // Simulate a language server reporting more errors for a file.
fake_language_server.notify::<lsp::notification::PublishDiagnostics>( fake_language_server.notify::<lsp::notification::PublishDiagnostics>(
&lsp::PublishDiagnosticsParams { &lsp::PublishDiagnosticsParams {
uri: lsp::Url::from_file_path("/a/a.rs").unwrap(), uri: lsp::Url::from_file_path(path!("/a/a.rs")).unwrap(),
version: None, version: None,
diagnostics: vec![ diagnostics: vec![
lsp::Diagnostic { lsp::Diagnostic {
@ -4219,7 +4236,7 @@ async fn test_collaborating_with_diagnostics(
// Simulate a language server reporting no errors for a file. // Simulate a language server reporting no errors for a file.
fake_language_server.notify::<lsp::notification::PublishDiagnostics>( fake_language_server.notify::<lsp::notification::PublishDiagnostics>(
&lsp::PublishDiagnosticsParams { &lsp::PublishDiagnosticsParams {
uri: lsp::Url::from_file_path("/a/a.rs").unwrap(), uri: lsp::Url::from_file_path(path!("/a/a.rs")).unwrap(),
version: None, version: None,
diagnostics: vec![], diagnostics: vec![],
}, },
@ -4275,7 +4292,7 @@ async fn test_collaborating_with_lsp_progress_updates_and_diagnostics_ordering(
client_a client_a
.fs() .fs()
.insert_tree( .insert_tree(
"/test", path!("/test"),
json!({ json!({
"one.rs": "const ONE: usize = 1;", "one.rs": "const ONE: usize = 1;",
"two.rs": "const TWO: usize = 2;", "two.rs": "const TWO: usize = 2;",
@ -4286,7 +4303,7 @@ async fn test_collaborating_with_lsp_progress_updates_and_diagnostics_ordering(
) )
.await; .await;
let (project_a, worktree_id) = client_a.build_local_project("/test", cx_a).await; let (project_a, worktree_id) = client_a.build_local_project(path!("/test"), cx_a).await;
// Share a project as client A // Share a project as client A
let active_call_a = cx_a.read(ActiveCall::global); let active_call_a = cx_a.read(ActiveCall::global);
@ -4325,7 +4342,7 @@ async fn test_collaborating_with_lsp_progress_updates_and_diagnostics_ordering(
for file_name in file_names { for file_name in file_names {
fake_language_server.notify::<lsp::notification::PublishDiagnostics>( fake_language_server.notify::<lsp::notification::PublishDiagnostics>(
&lsp::PublishDiagnosticsParams { &lsp::PublishDiagnosticsParams {
uri: lsp::Url::from_file_path(Path::new("/test").join(file_name)).unwrap(), uri: lsp::Url::from_file_path(Path::new(path!("/test")).join(file_name)).unwrap(),
version: None, version: None,
diagnostics: vec![lsp::Diagnostic { diagnostics: vec![lsp::Diagnostic {
severity: Some(lsp::DiagnosticSeverity::WARNING), severity: Some(lsp::DiagnosticSeverity::WARNING),
@ -4392,9 +4409,9 @@ async fn test_reloading_buffer_manually(
client_a client_a
.fs() .fs()
.insert_tree("/a", json!({ "a.rs": "let one = 1;" })) .insert_tree(path!("/a"), json!({ "a.rs": "let one = 1;" }))
.await; .await;
let (project_a, worktree_id) = client_a.build_local_project("/a", cx_a).await; let (project_a, worktree_id) = client_a.build_local_project(path!("/a"), cx_a).await;
let buffer_a = project_a let buffer_a = project_a
.update(cx_a, |p, cx| p.open_buffer((worktree_id, "a.rs"), cx)) .update(cx_a, |p, cx| p.open_buffer((worktree_id, "a.rs"), cx))
.await .await
@ -4422,7 +4439,7 @@ async fn test_reloading_buffer_manually(
client_a client_a
.fs() .fs()
.save( .save(
"/a/a.rs".as_ref(), path!("/a/a.rs").as_ref(),
&Rope::from("let seven = 7;"), &Rope::from("let seven = 7;"),
LineEnding::Unix, LineEnding::Unix,
) )
@ -4544,39 +4561,45 @@ async fn test_formatting_buffer(
"let honey = \"two\"\n" "let honey = \"two\"\n"
); );
// Ensure buffer can be formatted using an external command. Notice how the // There is no `awk` command on Windows.
// host's configuration is honored as opposed to using the guest's settings. #[cfg(not(target_os = "windows"))]
cx_a.update(|cx| { {
SettingsStore::update_global(cx, |store, cx| { // Ensure buffer can be formatted using an external command. Notice how the
store.update_user_settings::<AllLanguageSettings>(cx, |file| { // host's configuration is honored as opposed to using the guest's settings.
file.defaults.formatter = Some(SelectedFormatter::List(FormatterList( cx_a.update(|cx| {
vec![Formatter::External { SettingsStore::update_global(cx, |store, cx| {
command: "awk".into(), store.update_user_settings::<AllLanguageSettings>(cx, |file| {
arguments: Some(vec!["{sub(/two/,\"{buffer_path}\")}1".to_string()].into()), file.defaults.formatter = Some(SelectedFormatter::List(FormatterList(
}] vec![Formatter::External {
.into(), command: "awk".into(),
))); arguments: Some(
vec!["{sub(/two/,\"{buffer_path}\")}1".to_string()].into(),
),
}]
.into(),
)));
});
}); });
}); });
});
executor.allow_parking(); executor.allow_parking();
project_b project_b
.update(cx_b, |project, cx| { .update(cx_b, |project, cx| {
project.format( project.format(
HashSet::from_iter([buffer_b.clone()]), HashSet::from_iter([buffer_b.clone()]),
LspFormatTarget::Buffers, LspFormatTarget::Buffers,
true, true,
FormatTrigger::Save, FormatTrigger::Save,
cx, cx,
) )
}) })
.await .await
.unwrap(); .unwrap();
assert_eq!( assert_eq!(
buffer_b.read_with(cx_b, |buffer, _| buffer.text()), buffer_b.read_with(cx_b, |buffer, _| buffer.text()),
format!("let honey = \"{}/a.rs\"\n", directory.to_str().unwrap()) format!("let honey = \"{}/a.rs\"\n", directory.to_str().unwrap())
); );
}
} }
#[gpui::test(iterations = 10)] #[gpui::test(iterations = 10)]
@ -4734,7 +4757,7 @@ async fn test_definition(
client_a client_a
.fs() .fs()
.insert_tree( .insert_tree(
"/root", path!("/root"),
json!({ json!({
"dir-1": { "dir-1": {
"a.rs": "const ONE: usize = b::TWO + b::THREE;", "a.rs": "const ONE: usize = b::TWO + b::THREE;",
@ -4746,7 +4769,9 @@ async fn test_definition(
}), }),
) )
.await; .await;
let (project_a, worktree_id) = client_a.build_local_project("/root/dir-1", cx_a).await; let (project_a, worktree_id) = client_a
.build_local_project(path!("/root/dir-1"), cx_a)
.await;
let project_id = active_call_a let project_id = active_call_a
.update(cx_a, |call, cx| call.share_project(project_a.clone(), cx)) .update(cx_a, |call, cx| call.share_project(project_a.clone(), cx))
.await .await
@ -4767,7 +4792,7 @@ async fn test_definition(
|_, _| async move { |_, _| async move {
Ok(Some(lsp::GotoDefinitionResponse::Scalar( Ok(Some(lsp::GotoDefinitionResponse::Scalar(
lsp::Location::new( lsp::Location::new(
lsp::Url::from_file_path("/root/dir-2/b.rs").unwrap(), lsp::Url::from_file_path(path!("/root/dir-2/b.rs")).unwrap(),
lsp::Range::new(lsp::Position::new(0, 6), lsp::Position::new(0, 9)), lsp::Range::new(lsp::Position::new(0, 6), lsp::Position::new(0, 9)),
), ),
))) )))
@ -4798,7 +4823,7 @@ async fn test_definition(
|_, _| async move { |_, _| async move {
Ok(Some(lsp::GotoDefinitionResponse::Scalar( Ok(Some(lsp::GotoDefinitionResponse::Scalar(
lsp::Location::new( lsp::Location::new(
lsp::Url::from_file_path("/root/dir-2/b.rs").unwrap(), lsp::Url::from_file_path(path!("/root/dir-2/b.rs")).unwrap(),
lsp::Range::new(lsp::Position::new(1, 6), lsp::Position::new(1, 11)), lsp::Range::new(lsp::Position::new(1, 6), lsp::Position::new(1, 11)),
), ),
))) )))
@ -4835,7 +4860,7 @@ async fn test_definition(
); );
Ok(Some(lsp::GotoDefinitionResponse::Scalar( Ok(Some(lsp::GotoDefinitionResponse::Scalar(
lsp::Location::new( lsp::Location::new(
lsp::Url::from_file_path("/root/dir-2/c.rs").unwrap(), lsp::Url::from_file_path(path!("/root/dir-2/c.rs")).unwrap(),
lsp::Range::new(lsp::Position::new(0, 5), lsp::Position::new(0, 7)), lsp::Range::new(lsp::Position::new(0, 5), lsp::Position::new(0, 7)),
), ),
))) )))
@ -4887,7 +4912,7 @@ async fn test_references(
client_a client_a
.fs() .fs()
.insert_tree( .insert_tree(
"/root", path!("/root"),
json!({ json!({
"dir-1": { "dir-1": {
"one.rs": "const ONE: usize = 1;", "one.rs": "const ONE: usize = 1;",
@ -4899,7 +4924,9 @@ async fn test_references(
}), }),
) )
.await; .await;
let (project_a, worktree_id) = client_a.build_local_project("/root/dir-1", cx_a).await; let (project_a, worktree_id) = client_a
.build_local_project(path!("/root/dir-1"), cx_a)
.await;
let project_id = active_call_a let project_id = active_call_a
.update(cx_a, |call, cx| call.share_project(project_a.clone(), cx)) .update(cx_a, |call, cx| call.share_project(project_a.clone(), cx))
.await .await
@ -4922,7 +4949,7 @@ async fn test_references(
move |params, _| { move |params, _| {
assert_eq!( assert_eq!(
params.text_document_position.text_document.uri.as_str(), params.text_document_position.text_document.uri.as_str(),
"file:///root/dir-1/one.rs" uri!("file:///root/dir-1/one.rs")
); );
let rx = rx.clone(); let rx = rx.clone();
async move { async move {
@ -4951,15 +4978,15 @@ async fn test_references(
lsp_response_tx lsp_response_tx
.unbounded_send(Ok(Some(vec![ .unbounded_send(Ok(Some(vec![
lsp::Location { lsp::Location {
uri: lsp::Url::from_file_path("/root/dir-1/two.rs").unwrap(), uri: lsp::Url::from_file_path(path!("/root/dir-1/two.rs")).unwrap(),
range: lsp::Range::new(lsp::Position::new(0, 24), lsp::Position::new(0, 27)), range: lsp::Range::new(lsp::Position::new(0, 24), lsp::Position::new(0, 27)),
}, },
lsp::Location { lsp::Location {
uri: lsp::Url::from_file_path("/root/dir-1/two.rs").unwrap(), uri: lsp::Url::from_file_path(path!("/root/dir-1/two.rs")).unwrap(),
range: lsp::Range::new(lsp::Position::new(0, 35), lsp::Position::new(0, 38)), range: lsp::Range::new(lsp::Position::new(0, 35), lsp::Position::new(0, 38)),
}, },
lsp::Location { lsp::Location {
uri: lsp::Url::from_file_path("/root/dir-2/three.rs").unwrap(), uri: lsp::Url::from_file_path(path!("/root/dir-2/three.rs")).unwrap(),
range: lsp::Range::new(lsp::Position::new(0, 37), lsp::Position::new(0, 40)), range: lsp::Range::new(lsp::Position::new(0, 37), lsp::Position::new(0, 40)),
}, },
]))) ])))
@ -4984,7 +5011,7 @@ async fn test_references(
assert_eq!(references[1].buffer, references[0].buffer); assert_eq!(references[1].buffer, references[0].buffer);
assert_eq!( assert_eq!(
three_buffer.file().unwrap().full_path(cx), three_buffer.file().unwrap().full_path(cx),
Path::new("/root/dir-2/three.rs") Path::new(path!("/root/dir-2/three.rs"))
); );
assert_eq!(references[0].range.to_offset(two_buffer), 24..27); assert_eq!(references[0].range.to_offset(two_buffer), 24..27);
@ -5138,7 +5165,7 @@ async fn test_document_highlights(
client_a client_a
.fs() .fs()
.insert_tree( .insert_tree(
"/root-1", path!("/root-1"),
json!({ json!({
"main.rs": "fn double(number: i32) -> i32 { number + number }", "main.rs": "fn double(number: i32) -> i32 { number + number }",
}), }),
@ -5150,7 +5177,7 @@ async fn test_document_highlights(
.register_fake_lsp("Rust", Default::default()); .register_fake_lsp("Rust", Default::default());
client_a.language_registry().add(rust_lang()); client_a.language_registry().add(rust_lang());
let (project_a, worktree_id) = client_a.build_local_project("/root-1", cx_a).await; let (project_a, worktree_id) = client_a.build_local_project(path!("/root-1"), cx_a).await;
let project_id = active_call_a let project_id = active_call_a
.update(cx_a, |call, cx| call.share_project(project_a.clone(), cx)) .update(cx_a, |call, cx| call.share_project(project_a.clone(), cx))
.await .await
@ -5175,7 +5202,7 @@ async fn test_document_highlights(
.text_document .text_document
.uri .uri
.as_str(), .as_str(),
"file:///root-1/main.rs" uri!("file:///root-1/main.rs")
); );
assert_eq!( assert_eq!(
params.text_document_position_params.position, params.text_document_position_params.position,
@ -5238,7 +5265,7 @@ async fn test_lsp_hover(
client_a client_a
.fs() .fs()
.insert_tree( .insert_tree(
"/root-1", path!("/root-1"),
json!({ json!({
"main.rs": "use std::collections::HashMap;", "main.rs": "use std::collections::HashMap;",
}), }),
@ -5272,7 +5299,7 @@ async fn test_lsp_hover(
), ),
]; ];
let (project_a, worktree_id) = client_a.build_local_project("/root-1", cx_a).await; let (project_a, worktree_id) = client_a.build_local_project(path!("/root-1"), cx_a).await;
let project_id = active_call_a let project_id = active_call_a
.update(cx_a, |call, cx| call.share_project(project_a.clone(), cx)) .update(cx_a, |call, cx| call.share_project(project_a.clone(), cx))
.await .await
@ -5312,7 +5339,7 @@ async fn test_lsp_hover(
.text_document .text_document
.uri .uri
.as_str(), .as_str(),
"file:///root-1/main.rs" uri!("file:///root-1/main.rs")
); );
let name = new_server_name.clone(); let name = new_server_name.clone();
async move { async move {
@ -5338,7 +5365,7 @@ async fn test_lsp_hover(
.text_document .text_document
.uri .uri
.as_str(), .as_str(),
"file:///root-1/main.rs" uri!("file:///root-1/main.rs")
); );
assert_eq!( assert_eq!(
params.text_document_position_params.position, params.text_document_position_params.position,
@ -5445,7 +5472,7 @@ async fn test_project_symbols(
client_a client_a
.fs() .fs()
.insert_tree( .insert_tree(
"/code", path!("/code"),
json!({ json!({
"crate-1": { "crate-1": {
"one.rs": "const ONE: usize = 1;", "one.rs": "const ONE: usize = 1;",
@ -5459,7 +5486,9 @@ async fn test_project_symbols(
}), }),
) )
.await; .await;
let (project_a, worktree_id) = client_a.build_local_project("/code/crate-1", cx_a).await; let (project_a, worktree_id) = client_a
.build_local_project(path!("/code/crate-1"), cx_a)
.await;
let project_id = active_call_a let project_id = active_call_a
.update(cx_a, |call, cx| call.share_project(project_a.clone(), cx)) .update(cx_a, |call, cx| call.share_project(project_a.clone(), cx))
.await .await
@ -5482,7 +5511,7 @@ async fn test_project_symbols(
lsp::SymbolInformation { lsp::SymbolInformation {
name: "TWO".into(), name: "TWO".into(),
location: lsp::Location { location: lsp::Location {
uri: lsp::Url::from_file_path("/code/crate-2/two.rs").unwrap(), uri: lsp::Url::from_file_path(path!("/code/crate-2/two.rs")).unwrap(),
range: lsp::Range::new(lsp::Position::new(0, 6), lsp::Position::new(0, 9)), range: lsp::Range::new(lsp::Position::new(0, 6), lsp::Position::new(0, 9)),
}, },
kind: lsp::SymbolKind::CONSTANT, kind: lsp::SymbolKind::CONSTANT,
@ -5513,13 +5542,13 @@ async fn test_project_symbols(
buffer_b_2.read_with(cx_b, |buffer, cx| { buffer_b_2.read_with(cx_b, |buffer, cx| {
assert_eq!( assert_eq!(
buffer.file().unwrap().full_path(cx), buffer.file().unwrap().full_path(cx),
Path::new("/code/crate-2/two.rs") Path::new(path!("/code/crate-2/two.rs"))
); );
}); });
// Attempt to craft a symbol and violate host's privacy by opening an arbitrary file. // Attempt to craft a symbol and violate host's privacy by opening an arbitrary file.
let mut fake_symbol = symbols[0].clone(); let mut fake_symbol = symbols[0].clone();
fake_symbol.path.path = Path::new("/code/secrets").into(); fake_symbol.path.path = Path::new(path!("/code/secrets")).into();
let error = project_b let error = project_b
.update(cx_b, |project, cx| { .update(cx_b, |project, cx| {
project.open_buffer_for_symbol(&fake_symbol, cx) project.open_buffer_for_symbol(&fake_symbol, cx)
@ -5552,14 +5581,14 @@ async fn test_open_buffer_while_getting_definition_pointing_to_it(
client_a client_a
.fs() .fs()
.insert_tree( .insert_tree(
"/root", path!("/root"),
json!({ json!({
"a.rs": "const ONE: usize = b::TWO;", "a.rs": "const ONE: usize = b::TWO;",
"b.rs": "const TWO: usize = 2", "b.rs": "const TWO: usize = 2",
}), }),
) )
.await; .await;
let (project_a, worktree_id) = client_a.build_local_project("/root", cx_a).await; let (project_a, worktree_id) = client_a.build_local_project(path!("/root"), cx_a).await;
let project_id = active_call_a let project_id = active_call_a
.update(cx_a, |call, cx| call.share_project(project_a.clone(), cx)) .update(cx_a, |call, cx| call.share_project(project_a.clone(), cx))
.await .await
@ -5578,7 +5607,7 @@ async fn test_open_buffer_while_getting_definition_pointing_to_it(
|_, _| async move { |_, _| async move {
Ok(Some(lsp::GotoDefinitionResponse::Scalar( Ok(Some(lsp::GotoDefinitionResponse::Scalar(
lsp::Location::new( lsp::Location::new(
lsp::Url::from_file_path("/root/b.rs").unwrap(), lsp::Url::from_file_path(path!("/root/b.rs")).unwrap(),
lsp::Range::new(lsp::Position::new(0, 6), lsp::Position::new(0, 9)), lsp::Range::new(lsp::Position::new(0, 6), lsp::Position::new(0, 9)),
), ),
))) )))

View file

@ -27,7 +27,7 @@ use std::{
rc::Rc, rc::Rc,
sync::Arc, sync::Arc,
}; };
use util::ResultExt; use util::{path, ResultExt};
#[gpui::test( #[gpui::test(
iterations = 100, iterations = 100,
@ -280,7 +280,7 @@ impl RandomizedTest for ProjectCollaborationTest {
let mut paths = client.fs().paths(false); let mut paths = client.fs().paths(false);
paths.remove(0); paths.remove(0);
let new_root_path = if paths.is_empty() || rng.gen() { let new_root_path = if paths.is_empty() || rng.gen() {
Path::new("/").join(plan.next_root_dir_name()) Path::new(path!("/")).join(plan.next_root_dir_name())
} else { } else {
paths.choose(rng).unwrap().clone() paths.choose(rng).unwrap().clone()
}; };
@ -547,7 +547,7 @@ impl RandomizedTest for ProjectCollaborationTest {
first_root_name first_root_name
); );
let root_path = Path::new("/").join(&first_root_name); let root_path = Path::new(path!("/")).join(&first_root_name);
client.fs().create_dir(&root_path).await.unwrap(); client.fs().create_dir(&root_path).await.unwrap();
client client
.fs() .fs()

View file

@ -26,6 +26,7 @@ use remote_server::{HeadlessAppState, HeadlessProject};
use serde_json::json; use serde_json::json;
use settings::SettingsStore; use settings::SettingsStore;
use std::{path::Path, sync::Arc}; use std::{path::Path, sync::Arc};
use util::{path, separator};
#[gpui::test(iterations = 10)] #[gpui::test(iterations = 10)]
async fn test_sharing_an_ssh_remote_project( async fn test_sharing_an_ssh_remote_project(
@ -52,7 +53,7 @@ async fn test_sharing_an_ssh_remote_project(
let remote_fs = FakeFs::new(server_cx.executor()); let remote_fs = FakeFs::new(server_cx.executor());
remote_fs remote_fs
.insert_tree( .insert_tree(
"/code", path!("/code"),
json!({ json!({
"project1": { "project1": {
".zed": { ".zed": {
@ -92,7 +93,7 @@ async fn test_sharing_an_ssh_remote_project(
let client_ssh = SshRemoteClient::fake_client(opts, cx_a).await; let client_ssh = SshRemoteClient::fake_client(opts, cx_a).await;
let (project_a, worktree_id) = client_a let (project_a, worktree_id) = client_a
.build_ssh_project("/code/project1", client_ssh, cx_a) .build_ssh_project(path!("/code/project1"), client_ssh, cx_a)
.await; .await;
// While the SSH worktree is being scanned, user A shares the remote project. // While the SSH worktree is being scanned, user A shares the remote project.
@ -178,7 +179,7 @@ async fn test_sharing_an_ssh_remote_project(
.unwrap(); .unwrap();
assert_eq!( assert_eq!(
remote_fs remote_fs
.load("/code/project1/src/renamed.rs".as_ref()) .load(path!("/code/project1/src/renamed.rs").as_ref())
.await .await
.unwrap(), .unwrap(),
"fn one() -> usize { 100 }" "fn one() -> usize { 100 }"
@ -193,7 +194,7 @@ async fn test_sharing_an_ssh_remote_project(
.path() .path()
.to_string_lossy() .to_string_lossy()
.to_string(), .to_string(),
"src/renamed.rs".to_string() separator!("src/renamed.rs").to_string()
); );
}); });
} }
@ -408,7 +409,10 @@ async fn test_ssh_collaboration_formatting_with_prettier(
let buffer_text = "let one = \"two\""; let buffer_text = "let one = \"two\"";
let prettier_format_suffix = project::TEST_PRETTIER_FORMAT_SUFFIX; let prettier_format_suffix = project::TEST_PRETTIER_FORMAT_SUFFIX;
remote_fs remote_fs
.insert_tree("/project", serde_json::json!({ "a.ts": buffer_text })) .insert_tree(
path!("/project"),
serde_json::json!({ "a.ts": buffer_text }),
)
.await; .await;
let test_plugin = "test_plugin"; let test_plugin = "test_plugin";
@ -455,7 +459,7 @@ async fn test_ssh_collaboration_formatting_with_prettier(
let client_ssh = SshRemoteClient::fake_client(opts, cx_a).await; let client_ssh = SshRemoteClient::fake_client(opts, cx_a).await;
let (project_a, worktree_id) = client_a let (project_a, worktree_id) = client_a
.build_ssh_project("/project", client_ssh, cx_a) .build_ssh_project(path!("/project"), client_ssh, cx_a)
.await; .await;
// While the SSH worktree is being scanned, user A shares the remote project. // While the SSH worktree is being scanned, user A shares the remote project.

View file

@ -43,6 +43,7 @@ use std::{
Arc, Arc,
}, },
}; };
use util::path;
use workspace::{Workspace, WorkspaceStore}; use workspace::{Workspace, WorkspaceStore};
#[cfg(not(target_os = "macos"))] #[cfg(not(target_os = "macos"))]
@ -741,7 +742,7 @@ impl TestClient {
pub async fn build_test_project(&self, cx: &mut TestAppContext) -> Entity<Project> { pub async fn build_test_project(&self, cx: &mut TestAppContext) -> Entity<Project> {
self.fs() self.fs()
.insert_tree( .insert_tree(
"/a", path!("/a"),
json!({ json!({
"1.txt": "one\none\none", "1.txt": "one\none\none",
"2.js": "function two() { return 2; }", "2.js": "function two() { return 2; }",
@ -749,7 +750,7 @@ impl TestClient {
}), }),
) )
.await; .await;
self.build_local_project("/a", cx).await.0 self.build_local_project(path!("/a"), cx).await.0
} }
pub async fn host_workspace( pub async fn host_workspace(