v1
This commit is contained in:
parent
452006560e
commit
adc426b668
15 changed files with 4231 additions and 4182 deletions
|
@ -25,7 +25,7 @@ client2 = { path = "../client2" }
|
|||
clock = { path = "../clock" }
|
||||
collections = { path = "../collections" }
|
||||
db2 = { path = "../db2" }
|
||||
fs = { path = "../fs" }
|
||||
fs2 = { path = "../fs2" }
|
||||
fsevent = { path = "../fsevent" }
|
||||
fuzzy2 = { path = "../fuzzy2" }
|
||||
git = { path = "../git" }
|
||||
|
@ -71,7 +71,7 @@ pretty_assertions.workspace = true
|
|||
client2 = { path = "../client2", features = ["test-support"] }
|
||||
collections = { path = "../collections", features = ["test-support"] }
|
||||
db2 = { path = "../db2", features = ["test-support"] }
|
||||
fs = { path = "../fs", features = ["test-support"] }
|
||||
fs2 = { path = "../fs2", features = ["test-support"] }
|
||||
gpui2 = { path = "../gpui2", features = ["test-support"] }
|
||||
language2 = { path = "../language2", features = ["test-support"] }
|
||||
lsp2 = { path = "../lsp2", features = ["test-support"] }
|
||||
|
|
|
@ -89,7 +89,7 @@ use util::{
|
|||
post_inc, ResultExt, TryFutureExt as _,
|
||||
};
|
||||
|
||||
pub use fs::*;
|
||||
pub use fs2::*;
|
||||
pub use worktree::*;
|
||||
|
||||
pub trait Item {
|
||||
|
@ -842,39 +842,39 @@ impl Project {
|
|||
}
|
||||
}
|
||||
|
||||
// #[cfg(any(test, feature = "test-support"))]
|
||||
// pub async fn test(
|
||||
// fs: Arc<dyn Fs>,
|
||||
// root_paths: impl IntoIterator<Item = &Path>,
|
||||
// cx: &mut gpui::TestAppContext,
|
||||
// ) -> Handle<Project> {
|
||||
// let mut languages = LanguageRegistry::test();
|
||||
// languages.set_executor(cx.background());
|
||||
// let http_client = util::http::FakeHttpClient::with_404_response();
|
||||
// let client = cx.update(|cx| client2::Client::new(http_client.clone(), cx));
|
||||
// let user_store = cx.add_model(|cx| UserStore::new(client.clone(), http_client, cx));
|
||||
// let project = cx.update(|cx| {
|
||||
// Project::local(
|
||||
// client,
|
||||
// node_runtime::FakeNodeRuntime::new(),
|
||||
// user_store,
|
||||
// Arc::new(languages),
|
||||
// fs,
|
||||
// cx,
|
||||
// )
|
||||
// });
|
||||
// for path in root_paths {
|
||||
// let (tree, _) = project
|
||||
// .update(cx, |project, cx| {
|
||||
// project.find_or_create_local_worktree(path, true, cx)
|
||||
// })
|
||||
// .await
|
||||
// .unwrap();
|
||||
// tree.read_with(cx, |tree, _| tree.as_local().unwrap().scan_complete())
|
||||
// .await;
|
||||
// }
|
||||
// project
|
||||
// }
|
||||
#[cfg(any(test, feature = "test-support"))]
|
||||
pub async fn test(
|
||||
fs: Arc<dyn Fs>,
|
||||
root_paths: impl IntoIterator<Item = &Path>,
|
||||
cx: &mut gpui2::TestAppContext,
|
||||
) -> Handle<Project> {
|
||||
let mut languages = LanguageRegistry::test();
|
||||
languages.set_executor(cx.executor().clone());
|
||||
let http_client = util::http::FakeHttpClient::with_404_response();
|
||||
let client = cx.update(|cx| client2::Client::new(http_client.clone(), cx));
|
||||
let user_store = cx.entity(|cx| UserStore::new(client.clone(), http_client, cx));
|
||||
let project = cx.update(|cx| {
|
||||
Project::local(
|
||||
client,
|
||||
node_runtime::FakeNodeRuntime::new(),
|
||||
user_store,
|
||||
Arc::new(languages),
|
||||
fs,
|
||||
cx,
|
||||
)
|
||||
});
|
||||
for path in root_paths {
|
||||
let (tree, _) = project
|
||||
.update(cx, |project, cx| {
|
||||
project.find_or_create_local_worktree(path, true, cx)
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
tree.update(cx, |tree, _| tree.as_local().unwrap().scan_complete())
|
||||
.await;
|
||||
}
|
||||
project
|
||||
}
|
||||
|
||||
/// Enables a prettier mock that avoids interacting with node runtime, prettier LSP wrapper, or any real file changes.
|
||||
/// Instead, if appends the suffix to every input, this suffix is returned by this method.
|
||||
|
@ -5199,7 +5199,7 @@ impl Project {
|
|||
fs.create_file(
|
||||
&abs_path,
|
||||
op.options
|
||||
.map(|options| fs::CreateOptions {
|
||||
.map(|options| fs2::CreateOptions {
|
||||
overwrite: options.overwrite.unwrap_or(false),
|
||||
ignore_if_exists: options.ignore_if_exists.unwrap_or(false),
|
||||
})
|
||||
|
@ -5222,7 +5222,7 @@ impl Project {
|
|||
&source_abs_path,
|
||||
&target_abs_path,
|
||||
op.options
|
||||
.map(|options| fs::RenameOptions {
|
||||
.map(|options| fs2::RenameOptions {
|
||||
overwrite: options.overwrite.unwrap_or(false),
|
||||
ignore_if_exists: options.ignore_if_exists.unwrap_or(false),
|
||||
})
|
||||
|
@ -5238,7 +5238,7 @@ impl Project {
|
|||
.map_err(|_| anyhow!("can't convert URI to path"))?;
|
||||
let options = op
|
||||
.options
|
||||
.map(|options| fs::RemoveOptions {
|
||||
.map(|options| fs2::RemoveOptions {
|
||||
recursive: options.recursive.unwrap_or(false),
|
||||
ignore_if_not_exists: options.ignore_if_not_exists.unwrap_or(false),
|
||||
})
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -6,7 +6,7 @@ use anyhow::{anyhow, Context as _, Result};
|
|||
use client2::{proto, Client};
|
||||
use clock::ReplicaId;
|
||||
use collections::{HashMap, HashSet, VecDeque};
|
||||
use fs::{
|
||||
use fs2::{
|
||||
repository::{GitFileStatus, GitRepository, RepoPath},
|
||||
Fs,
|
||||
};
|
||||
|
@ -2815,7 +2815,7 @@ pub type UpdatedGitRepositoriesSet = Arc<[(Arc<Path>, GitRepositoryChange)]>;
|
|||
impl Entry {
|
||||
fn new(
|
||||
path: Arc<Path>,
|
||||
metadata: &fs::Metadata,
|
||||
metadata: &fs2::Metadata,
|
||||
next_entry_id: &AtomicUsize,
|
||||
root_char_bag: CharBag,
|
||||
) -> Self {
|
||||
|
@ -4030,53 +4030,52 @@ struct UpdateIgnoreStatusJob {
|
|||
scan_queue: Sender<ScanJob>,
|
||||
}
|
||||
|
||||
// todo!("re-enable when we have tests")
|
||||
// pub trait WorktreeModelHandle {
|
||||
// #[cfg(any(test, feature = "test-support"))]
|
||||
// fn flush_fs_events<'a>(
|
||||
// &self,
|
||||
// cx: &'a gpui::TestAppContext,
|
||||
// ) -> futures::future::LocalBoxFuture<'a, ()>;
|
||||
// }
|
||||
pub trait WorktreeModelHandle {
|
||||
#[cfg(any(test, feature = "test-support"))]
|
||||
fn flush_fs_events<'a>(
|
||||
&self,
|
||||
cx: &'a mut gpui2::TestAppContext,
|
||||
) -> futures::future::LocalBoxFuture<'a, ()>;
|
||||
}
|
||||
|
||||
// impl WorktreeModelHandle for Handle<Worktree> {
|
||||
// // When the worktree's FS event stream sometimes delivers "redundant" events for FS changes that
|
||||
// // occurred before the worktree was constructed. These events can cause the worktree to perform
|
||||
// // extra directory scans, and emit extra scan-state notifications.
|
||||
// //
|
||||
// // This function mutates the worktree's directory and waits for those mutations to be picked up,
|
||||
// // to ensure that all redundant FS events have already been processed.
|
||||
// #[cfg(any(test, feature = "test-support"))]
|
||||
// fn flush_fs_events<'a>(
|
||||
// &self,
|
||||
// cx: &'a gpui::TestAppContext,
|
||||
// ) -> futures::future::LocalBoxFuture<'a, ()> {
|
||||
// let filename = "fs-event-sentinel";
|
||||
// let tree = self.clone();
|
||||
// let (fs, root_path) = self.read_with(cx, |tree, _| {
|
||||
// let tree = tree.as_local().unwrap();
|
||||
// (tree.fs.clone(), tree.abs_path().clone())
|
||||
// });
|
||||
impl WorktreeModelHandle for Handle<Worktree> {
|
||||
// When the worktree's FS event stream sometimes delivers "redundant" events for FS changes that
|
||||
// occurred before the worktree was constructed. These events can cause the worktree to perform
|
||||
// extra directory scans, and emit extra scan-state notifications.
|
||||
//
|
||||
// This function mutates the worktree's directory and waits for those mutations to be picked up,
|
||||
// to ensure that all redundant FS events have already been processed.
|
||||
#[cfg(any(test, feature = "test-support"))]
|
||||
fn flush_fs_events<'a>(
|
||||
&self,
|
||||
cx: &'a mut gpui2::TestAppContext,
|
||||
) -> futures::future::LocalBoxFuture<'a, ()> {
|
||||
let filename = "fs-event-sentinel";
|
||||
let tree = self.clone();
|
||||
let (fs, root_path) = self.update(cx, |tree, _| {
|
||||
let tree = tree.as_local().unwrap();
|
||||
(tree.fs.clone(), tree.abs_path().clone())
|
||||
});
|
||||
|
||||
// async move {
|
||||
// fs.create_file(&root_path.join(filename), Default::default())
|
||||
// .await
|
||||
// .unwrap();
|
||||
// tree.condition(cx, |tree, _| tree.entry_for_path(filename).is_some())
|
||||
// .await;
|
||||
async move {
|
||||
fs.create_file(&root_path.join(filename), Default::default())
|
||||
.await
|
||||
.unwrap();
|
||||
cx.executor().run_until_parked();
|
||||
assert!(tree.update(cx, |tree, _| tree.entry_for_path(filename).is_some()));
|
||||
|
||||
// fs.remove_file(&root_path.join(filename), Default::default())
|
||||
// .await
|
||||
// .unwrap();
|
||||
// tree.condition(cx, |tree, _| tree.entry_for_path(filename).is_none())
|
||||
// .await;
|
||||
fs.remove_file(&root_path.join(filename), Default::default())
|
||||
.await
|
||||
.unwrap();
|
||||
cx.executor().run_until_parked();
|
||||
assert!(tree.update(cx, |tree, _| tree.entry_for_path(filename).is_none()));
|
||||
|
||||
// cx.read(|cx| tree.read(cx).as_local().unwrap().scan_complete())
|
||||
// .await;
|
||||
// }
|
||||
// .boxed_local()
|
||||
// }
|
||||
// }
|
||||
cx.update(|cx| tree.read(cx).as_local().unwrap().scan_complete())
|
||||
.await;
|
||||
}
|
||||
.boxed_local()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
struct TraversalProgress<'a> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue