Use FakeFs in worktree gitignore test
This commit is contained in:
parent
91f87bb31f
commit
201188fdaa
1 changed files with 41 additions and 23 deletions
|
@ -703,31 +703,33 @@ async fn test_dirs_no_longer_ignored(cx: &mut TestAppContext) {
|
||||||
assert_eq!(read_dir_count_3 - read_dir_count_2, 2);
|
assert_eq!(read_dir_count_3 - read_dir_count_2, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test]
|
#[gpui::test(iterations = 10)]
|
||||||
async fn test_rescan_with_gitignore(cx: &mut TestAppContext) {
|
async fn test_rescan_with_gitignore(cx: &mut TestAppContext) {
|
||||||
// .gitignores are handled explicitly by Zed and do not use the git
|
let fs = FakeFs::new(cx.background());
|
||||||
// machinery that the git_tests module checks
|
fs.insert_tree(
|
||||||
let parent_dir = temp_tree(json!({
|
"/root",
|
||||||
".gitignore": "ancestor-ignored-file1\nancestor-ignored-file2\n",
|
json!({
|
||||||
"tree": {
|
".gitignore": "ancestor-ignored-file1\nancestor-ignored-file2\n",
|
||||||
".git": {},
|
"tree": {
|
||||||
".gitignore": "ignored-dir\n",
|
".git": {},
|
||||||
"tracked-dir": {
|
".gitignore": "ignored-dir\n",
|
||||||
"tracked-file1": "",
|
"tracked-dir": {
|
||||||
"ancestor-ignored-file1": "",
|
"tracked-file1": "",
|
||||||
},
|
"ancestor-ignored-file1": "",
|
||||||
"ignored-dir": {
|
},
|
||||||
"ignored-file1": ""
|
"ignored-dir": {
|
||||||
|
"ignored-file1": ""
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}),
|
||||||
}));
|
)
|
||||||
let dir = parent_dir.path().join("tree");
|
.await;
|
||||||
|
|
||||||
let tree = Worktree::local(
|
let tree = Worktree::local(
|
||||||
build_client(cx),
|
build_client(cx),
|
||||||
dir.as_path(),
|
"/root/tree".as_ref(),
|
||||||
true,
|
true,
|
||||||
Arc::new(RealFs),
|
fs.clone(),
|
||||||
Default::default(),
|
Default::default(),
|
||||||
&mut cx.to_async(),
|
&mut cx.to_async(),
|
||||||
)
|
)
|
||||||
|
@ -764,10 +766,26 @@ async fn test_rescan_with_gitignore(cx: &mut TestAppContext) {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
std::fs::write(dir.join("tracked-dir/tracked-file2"), "").unwrap();
|
fs.create_file(
|
||||||
std::fs::write(dir.join("tracked-dir/ancestor-ignored-file2"), "").unwrap();
|
"/root/tree/tracked-dir/tracked-file2".as_ref(),
|
||||||
std::fs::write(dir.join("ignored-dir/ignored-file2"), "").unwrap();
|
Default::default(),
|
||||||
tree.flush_fs_events(cx).await;
|
)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
fs.create_file(
|
||||||
|
"/root/tree/tracked-dir/ancestor-ignored-file2".as_ref(),
|
||||||
|
Default::default(),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
fs.create_file(
|
||||||
|
"/root/tree/ignored-dir/ignored-file2".as_ref(),
|
||||||
|
Default::default(),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
cx.foreground().run_until_parked();
|
||||||
cx.read(|cx| {
|
cx.read(|cx| {
|
||||||
let tree = tree.read(cx);
|
let tree = tree.read(cx);
|
||||||
assert!(
|
assert!(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue