windows: Fix tests on Windows (#22616)
Release Notes: - N/A --------- Co-authored-by: Mikayla <mikayla.c.maki@gmail.com>
This commit is contained in:
parent
c252b5db16
commit
74c4dbd237
56 changed files with 1540 additions and 856 deletions
|
@ -1,3 +1,6 @@
|
|||
/// todo(windows)
|
||||
/// The tests in this file assume that server_cx is running on Windows too.
|
||||
/// We neead to find a way to test Windows-Non-Windows interactions.
|
||||
use crate::headless_project::HeadlessProject;
|
||||
use client::{Client, UserStore};
|
||||
use clock::FakeSystemClock;
|
||||
|
@ -24,12 +27,13 @@ use std::{
|
|||
path::{Path, PathBuf},
|
||||
sync::Arc,
|
||||
};
|
||||
use util::{path, separator};
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_basic_remote_editing(cx: &mut TestAppContext, server_cx: &mut TestAppContext) {
|
||||
let fs = FakeFs::new(server_cx.executor());
|
||||
fs.insert_tree(
|
||||
"/code",
|
||||
path!("/code"),
|
||||
json!({
|
||||
"project1": {
|
||||
".git": {},
|
||||
|
@ -45,14 +49,14 @@ async fn test_basic_remote_editing(cx: &mut TestAppContext, server_cx: &mut Test
|
|||
)
|
||||
.await;
|
||||
fs.set_index_for_repo(
|
||||
Path::new("/code/project1/.git"),
|
||||
Path::new(path!("/code/project1/.git")),
|
||||
&[("src/lib.rs".into(), "fn one() -> usize { 0 }".into())],
|
||||
);
|
||||
|
||||
let (project, _headless) = init_test(&fs, cx, server_cx).await;
|
||||
let (worktree, _) = project
|
||||
.update(cx, |project, cx| {
|
||||
project.find_or_create_worktree("/code/project1", true, cx)
|
||||
project.find_or_create_worktree(path!("/code/project1"), true, cx)
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
|
@ -113,7 +117,7 @@ async fn test_basic_remote_editing(cx: &mut TestAppContext, server_cx: &mut Test
|
|||
// A new file is created in the remote filesystem. The user
|
||||
// sees the new file.
|
||||
fs.save(
|
||||
"/code/project1/src/main.rs".as_ref(),
|
||||
path!("/code/project1/src/main.rs").as_ref(),
|
||||
&"fn main() {}".into(),
|
||||
Default::default(),
|
||||
)
|
||||
|
@ -134,8 +138,8 @@ async fn test_basic_remote_editing(cx: &mut TestAppContext, server_cx: &mut Test
|
|||
|
||||
// A file that is currently open in a buffer is renamed.
|
||||
fs.rename(
|
||||
"/code/project1/src/lib.rs".as_ref(),
|
||||
"/code/project1/src/lib2.rs".as_ref(),
|
||||
path!("/code/project1/src/lib.rs").as_ref(),
|
||||
path!("/code/project1/src/lib2.rs").as_ref(),
|
||||
Default::default(),
|
||||
)
|
||||
.await
|
||||
|
@ -146,7 +150,7 @@ async fn test_basic_remote_editing(cx: &mut TestAppContext, server_cx: &mut Test
|
|||
});
|
||||
|
||||
fs.set_index_for_repo(
|
||||
Path::new("/code/project1/.git"),
|
||||
Path::new(path!("/code/project1/.git")),
|
||||
&[("src/lib2.rs".into(), "fn one() -> usize { 100 }".into())],
|
||||
);
|
||||
cx.executor().run_until_parked();
|
||||
|
@ -162,7 +166,7 @@ async fn test_basic_remote_editing(cx: &mut TestAppContext, server_cx: &mut Test
|
|||
async fn test_remote_project_search(cx: &mut TestAppContext, server_cx: &mut TestAppContext) {
|
||||
let fs = FakeFs::new(server_cx.executor());
|
||||
fs.insert_tree(
|
||||
"/code",
|
||||
path!("/code"),
|
||||
json!({
|
||||
"project1": {
|
||||
".git": {},
|
||||
|
@ -179,7 +183,7 @@ async fn test_remote_project_search(cx: &mut TestAppContext, server_cx: &mut Tes
|
|||
|
||||
project
|
||||
.update(cx, |project, cx| {
|
||||
project.find_or_create_worktree("/code/project1", true, cx)
|
||||
project.find_or_create_worktree(path!("/code/project1"), true, cx)
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
|
@ -210,7 +214,7 @@ async fn test_remote_project_search(cx: &mut TestAppContext, server_cx: &mut Tes
|
|||
buffer.update(&mut cx, |buffer, cx| {
|
||||
assert_eq!(
|
||||
buffer.file().unwrap().full_path(cx).to_string_lossy(),
|
||||
"project1/README.md"
|
||||
separator!("project1/README.md")
|
||||
)
|
||||
});
|
||||
|
||||
|
@ -368,7 +372,7 @@ async fn test_remote_settings(cx: &mut TestAppContext, server_cx: &mut TestAppCo
|
|||
async fn test_remote_lsp(cx: &mut TestAppContext, server_cx: &mut TestAppContext) {
|
||||
let fs = FakeFs::new(server_cx.executor());
|
||||
fs.insert_tree(
|
||||
"/code",
|
||||
path!("/code"),
|
||||
json!({
|
||||
"project1": {
|
||||
".git": {},
|
||||
|
@ -384,7 +388,7 @@ async fn test_remote_lsp(cx: &mut TestAppContext, server_cx: &mut TestAppContext
|
|||
let (project, headless) = init_test(&fs, cx, server_cx).await;
|
||||
|
||||
fs.insert_tree(
|
||||
"/code/project1/.zed",
|
||||
path!("/code/project1/.zed"),
|
||||
json!({
|
||||
"settings.json": r#"
|
||||
{
|
||||
|
@ -431,7 +435,7 @@ async fn test_remote_lsp(cx: &mut TestAppContext, server_cx: &mut TestAppContext
|
|||
|
||||
let worktree_id = project
|
||||
.update(cx, |project, cx| {
|
||||
project.find_or_create_worktree("/code/project1", true, cx)
|
||||
project.find_or_create_worktree(path!("/code/project1"), true, cx)
|
||||
})
|
||||
.await
|
||||
.unwrap()
|
||||
|
@ -512,7 +516,7 @@ async fn test_remote_lsp(cx: &mut TestAppContext, server_cx: &mut TestAppContext
|
|||
Ok(Some(lsp::WorkspaceEdit {
|
||||
changes: Some(
|
||||
[(
|
||||
lsp::Url::from_file_path("/code/project1/src/lib.rs").unwrap(),
|
||||
lsp::Url::from_file_path(path!("/code/project1/src/lib.rs")).unwrap(),
|
||||
vec![lsp::TextEdit::new(
|
||||
lsp::Range::new(lsp::Position::new(0, 3), lsp::Position::new(0, 6)),
|
||||
"two".to_string(),
|
||||
|
@ -545,7 +549,7 @@ async fn test_remote_cancel_language_server_work(
|
|||
) {
|
||||
let fs = FakeFs::new(server_cx.executor());
|
||||
fs.insert_tree(
|
||||
"/code",
|
||||
path!("/code"),
|
||||
json!({
|
||||
"project1": {
|
||||
".git": {},
|
||||
|
@ -561,7 +565,7 @@ async fn test_remote_cancel_language_server_work(
|
|||
let (project, headless) = init_test(&fs, cx, server_cx).await;
|
||||
|
||||
fs.insert_tree(
|
||||
"/code/project1/.zed",
|
||||
path!("/code/project1/.zed"),
|
||||
json!({
|
||||
"settings.json": r#"
|
||||
{
|
||||
|
@ -608,7 +612,7 @@ async fn test_remote_cancel_language_server_work(
|
|||
|
||||
let worktree_id = project
|
||||
.update(cx, |project, cx| {
|
||||
project.find_or_create_worktree("/code/project1", true, cx)
|
||||
project.find_or_create_worktree(path!("/code/project1"), true, cx)
|
||||
})
|
||||
.await
|
||||
.unwrap()
|
||||
|
@ -708,7 +712,7 @@ async fn test_remote_cancel_language_server_work(
|
|||
async fn test_remote_reload(cx: &mut TestAppContext, server_cx: &mut TestAppContext) {
|
||||
let fs = FakeFs::new(server_cx.executor());
|
||||
fs.insert_tree(
|
||||
"/code",
|
||||
path!("/code"),
|
||||
json!({
|
||||
"project1": {
|
||||
".git": {},
|
||||
|
@ -724,7 +728,7 @@ async fn test_remote_reload(cx: &mut TestAppContext, server_cx: &mut TestAppCont
|
|||
let (project, _headless) = init_test(&fs, cx, server_cx).await;
|
||||
let (worktree, _) = project
|
||||
.update(cx, |project, cx| {
|
||||
project.find_or_create_worktree("/code/project1", true, cx)
|
||||
project.find_or_create_worktree(path!("/code/project1"), true, cx)
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
|
@ -739,7 +743,7 @@ async fn test_remote_reload(cx: &mut TestAppContext, server_cx: &mut TestAppCont
|
|||
.unwrap();
|
||||
|
||||
fs.save(
|
||||
&PathBuf::from("/code/project1/src/lib.rs"),
|
||||
&PathBuf::from(path!("/code/project1/src/lib.rs")),
|
||||
&("bangles".to_string().into()),
|
||||
LineEnding::Unix,
|
||||
)
|
||||
|
@ -754,7 +758,7 @@ async fn test_remote_reload(cx: &mut TestAppContext, server_cx: &mut TestAppCont
|
|||
});
|
||||
|
||||
fs.save(
|
||||
&PathBuf::from("/code/project1/src/lib.rs"),
|
||||
&PathBuf::from(path!("/code/project1/src/lib.rs")),
|
||||
&("bloop".to_string().into()),
|
||||
LineEnding::Unix,
|
||||
)
|
||||
|
@ -786,7 +790,7 @@ async fn test_remote_resolve_path_in_buffer(
|
|||
) {
|
||||
let fs = FakeFs::new(server_cx.executor());
|
||||
fs.insert_tree(
|
||||
"/code",
|
||||
path!("/code"),
|
||||
json!({
|
||||
"project1": {
|
||||
".git": {},
|
||||
|
@ -802,7 +806,7 @@ async fn test_remote_resolve_path_in_buffer(
|
|||
let (project, _headless) = init_test(&fs, cx, server_cx).await;
|
||||
let (worktree, _) = project
|
||||
.update(cx, |project, cx| {
|
||||
project.find_or_create_worktree("/code/project1", true, cx)
|
||||
project.find_or_create_worktree(path!("/code/project1"), true, cx)
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
|
@ -818,14 +822,14 @@ async fn test_remote_resolve_path_in_buffer(
|
|||
|
||||
let path = project
|
||||
.update(cx, |project, cx| {
|
||||
project.resolve_path_in_buffer("/code/project1/README.md", &buffer, cx)
|
||||
project.resolve_path_in_buffer(path!("/code/project1/README.md"), &buffer, cx)
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
assert!(path.is_file());
|
||||
assert_eq!(
|
||||
path.abs_path().unwrap().to_string_lossy(),
|
||||
"/code/project1/README.md"
|
||||
path!("/code/project1/README.md")
|
||||
);
|
||||
|
||||
let path = project
|
||||
|
@ -1013,7 +1017,7 @@ async fn test_adding_then_removing_then_adding_worktrees(
|
|||
async fn test_open_server_settings(cx: &mut TestAppContext, server_cx: &mut TestAppContext) {
|
||||
let fs = FakeFs::new(server_cx.executor());
|
||||
fs.insert_tree(
|
||||
"/code",
|
||||
path!("/code"),
|
||||
json!({
|
||||
"project1": {
|
||||
".git": {},
|
||||
|
@ -1035,7 +1039,9 @@ async fn test_open_server_settings(cx: &mut TestAppContext, server_cx: &mut Test
|
|||
cx.update(|cx| {
|
||||
assert_eq!(
|
||||
buffer.read(cx).text(),
|
||||
initial_server_settings_content().to_string()
|
||||
initial_server_settings_content()
|
||||
.to_string()
|
||||
.replace("\r\n", "\n")
|
||||
)
|
||||
})
|
||||
}
|
||||
|
@ -1044,7 +1050,7 @@ async fn test_open_server_settings(cx: &mut TestAppContext, server_cx: &mut Test
|
|||
async fn test_reconnect(cx: &mut TestAppContext, server_cx: &mut TestAppContext) {
|
||||
let fs = FakeFs::new(server_cx.executor());
|
||||
fs.insert_tree(
|
||||
"/code",
|
||||
path!("/code"),
|
||||
json!({
|
||||
"project1": {
|
||||
".git": {},
|
||||
|
@ -1061,7 +1067,7 @@ async fn test_reconnect(cx: &mut TestAppContext, server_cx: &mut TestAppContext)
|
|||
|
||||
let (worktree, _) = project
|
||||
.update(cx, |project, cx| {
|
||||
project.find_or_create_worktree("/code/project1", true, cx)
|
||||
project.find_or_create_worktree(path!("/code/project1"), true, cx)
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
|
@ -1091,7 +1097,9 @@ async fn test_reconnect(cx: &mut TestAppContext, server_cx: &mut TestAppContext)
|
|||
.unwrap();
|
||||
|
||||
assert_eq!(
|
||||
fs.load("/code/project1/src/lib.rs".as_ref()).await.unwrap(),
|
||||
fs.load(path!("/code/project1/src/lib.rs").as_ref())
|
||||
.await
|
||||
.unwrap(),
|
||||
"fn one() -> usize { 100 }"
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue