Fix hangs in new dispatcher
Co-authored-by: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
parent
90facc051a
commit
6ee93125d0
11 changed files with 93 additions and 44 deletions
|
@ -877,17 +877,14 @@ impl Project {
|
|||
)
|
||||
});
|
||||
for path in root_paths {
|
||||
dbg!(&path);
|
||||
let (tree, _) = project
|
||||
.update(cx, |project, cx| {
|
||||
project.find_or_create_local_worktree(path, true, cx)
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
dbg!("aaa");
|
||||
tree.update(cx, |tree, _| tree.as_local().unwrap().scan_complete())
|
||||
.await;
|
||||
dbg!("bbb");
|
||||
}
|
||||
project
|
||||
}
|
||||
|
@ -5993,10 +5990,8 @@ impl Project {
|
|||
) -> Task<Result<(Model<Worktree>, PathBuf)>> {
|
||||
let abs_path = abs_path.as_ref();
|
||||
if let Some((tree, relative_path)) = self.find_local_worktree(abs_path, cx) {
|
||||
dbg!("shortcut");
|
||||
Task::ready(Ok((tree, relative_path)))
|
||||
} else {
|
||||
dbg!("long cut");
|
||||
let worktree = self.create_local_worktree(abs_path, visible, cx);
|
||||
cx.background_executor()
|
||||
.spawn(async move { Ok((worktree.await?, PathBuf::new())) })
|
||||
|
|
|
@ -15,6 +15,36 @@ use std::{os, task::Poll};
|
|||
use unindent::Unindent as _;
|
||||
use util::{assert_set_eq, test::temp_tree};
|
||||
|
||||
#[gpui2::test]
|
||||
async fn test_block_via_channel(cx: &mut gpui2::TestAppContext) {
|
||||
cx.executor().allow_parking();
|
||||
|
||||
let (tx, mut rx) = futures::channel::mpsc::unbounded();
|
||||
let _thread = std::thread::spawn(move || {
|
||||
std::fs::metadata("/Users").unwrap();
|
||||
std::thread::sleep(Duration::from_millis(1000));
|
||||
tx.unbounded_send(1).unwrap();
|
||||
});
|
||||
rx.next().await.unwrap();
|
||||
}
|
||||
|
||||
#[gpui2::test]
|
||||
async fn test_block_via_smol(cx: &mut gpui2::TestAppContext) {
|
||||
cx.executor().allow_parking();
|
||||
|
||||
let io_task = smol::unblock(move || {
|
||||
println!("sleeping on thread {:?}", std::thread::current().id());
|
||||
std::thread::sleep(Duration::from_millis(10));
|
||||
1
|
||||
});
|
||||
|
||||
let task = cx.foreground_executor().spawn(async move {
|
||||
io_task.await;
|
||||
});
|
||||
|
||||
task.await;
|
||||
}
|
||||
|
||||
#[gpui2::test]
|
||||
async fn test_symlinks(cx: &mut gpui2::TestAppContext) {
|
||||
init_test(cx);
|
||||
|
@ -35,8 +65,6 @@ async fn test_symlinks(cx: &mut gpui2::TestAppContext) {
|
|||
}
|
||||
}));
|
||||
|
||||
dbg!("GOT HERE");
|
||||
|
||||
let root_link_path = dir.path().join("root_link");
|
||||
os::unix::fs::symlink(&dir.path().join("root"), &root_link_path).unwrap();
|
||||
os::unix::fs::symlink(
|
||||
|
@ -45,11 +73,8 @@ async fn test_symlinks(cx: &mut gpui2::TestAppContext) {
|
|||
)
|
||||
.unwrap();
|
||||
|
||||
dbg!("GOT HERE 2");
|
||||
|
||||
let project = Project::test(Arc::new(RealFs), [root_link_path.as_ref()], cx).await;
|
||||
|
||||
dbg!("GOT HERE 2.5");
|
||||
project.update(cx, |project, cx| {
|
||||
let tree = project.worktrees().next().unwrap().read(cx);
|
||||
assert_eq!(tree.file_count(), 5);
|
||||
|
@ -58,8 +83,6 @@ async fn test_symlinks(cx: &mut gpui2::TestAppContext) {
|
|||
tree.inode_for_path("finnochio/grape")
|
||||
);
|
||||
});
|
||||
|
||||
dbg!("GOT HERE 3");
|
||||
}
|
||||
|
||||
#[gpui2::test]
|
||||
|
@ -2706,7 +2729,7 @@ async fn test_save_as(cx: &mut gpui2::TestAppContext) {
|
|||
#[gpui2::test(retries = 5)]
|
||||
async fn test_rescan_and_remote_updates(cx: &mut gpui2::TestAppContext) {
|
||||
init_test(cx);
|
||||
// cx.executor().allow_parking();
|
||||
cx.executor().allow_parking();
|
||||
|
||||
let dir = temp_tree(json!({
|
||||
"a": {
|
||||
|
|
|
@ -297,15 +297,12 @@ impl Worktree {
|
|||
// After determining whether the root entry is a file or a directory, populate the
|
||||
// snapshot's "root name", which will be used for the purpose of fuzzy matching.
|
||||
let abs_path = path.into();
|
||||
eprintln!("get root metadata");
|
||||
|
||||
let metadata = fs
|
||||
.metadata(&abs_path)
|
||||
.await
|
||||
.context("failed to stat worktree path")?;
|
||||
|
||||
eprintln!("got root metadata");
|
||||
|
||||
cx.build_model(move |cx: &mut ModelContext<Worktree>| {
|
||||
let root_name = abs_path
|
||||
.file_name()
|
||||
|
@ -4067,13 +4064,12 @@ impl WorktreeModelHandle for Model<Worktree> {
|
|||
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();
|
||||
cx.executor().run_until_parked();
|
||||
assert!(tree.update(cx, |tree, _| tree.entry_for_path(filename).is_none()));
|
||||
|
||||
cx.update(|cx| tree.read(cx).as_local().unwrap().scan_complete())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue