fix display map tests
These tests failed due to an indefinite hang in buffer.condition in the following code: \`\`\`rust let buffer = cx .add_model(|cx| Buffer::new(0, cx.model_id() as u64, text).with_language(language, cx)); buffer.condition(cx, |buf, _| !buf.is_parsing()).await; `\`\` In both gpui1 and gpui2 \`.with_language\` spawns a task that notifies the context once it's done. The \`condition\` waits for notifications to be raised. The gist of the problem was that in gpui2, the spawned task was scheduled straight away, so we never really saw the notification with \`condition\`, causing us to wait indefinitely. This is probably a difference in test between schedulers in gpui1 and gpui2, but I kind of sidestepped the issue by spawning a condition before firing off a parsing task with \`set_language\`.
This commit is contained in:
parent
9ffe78d264
commit
0f7fc8c1a0
3 changed files with 42 additions and 31 deletions
|
@ -4187,7 +4187,7 @@ impl WorktreeModelHandle for Model<Worktree> {
|
|||
&self,
|
||||
cx: &'a mut gpui::TestAppContext,
|
||||
) -> futures::future::LocalBoxFuture<'a, ()> {
|
||||
let file_name = "fs-event-sentinel";
|
||||
let file_name: &'static str = "fs-event-sentinel";
|
||||
|
||||
let tree = self.clone();
|
||||
let (fs, root_path) = self.update(cx, |tree, _| {
|
||||
|
@ -4200,14 +4200,18 @@ impl WorktreeModelHandle for Model<Worktree> {
|
|||
.await
|
||||
.unwrap();
|
||||
|
||||
cx.condition(&tree, |tree, _| tree.entry_for_path(file_name).is_some())
|
||||
.await;
|
||||
cx.condition(&tree, move |tree, _| {
|
||||
tree.entry_for_path(file_name).is_some()
|
||||
})
|
||||
.await;
|
||||
|
||||
fs.remove_file(&root_path.join(file_name), Default::default())
|
||||
.await
|
||||
.unwrap();
|
||||
cx.condition(&tree, |tree, _| tree.entry_for_path(file_name).is_none())
|
||||
.await;
|
||||
cx.condition(&tree, move |tree, _| {
|
||||
tree.entry_for_path(file_name).is_none()
|
||||
})
|
||||
.await;
|
||||
|
||||
cx.update(|cx| tree.read(cx).as_local().unwrap().scan_complete())
|
||||
.await;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue