diff --git a/Cargo.lock b/Cargo.lock index 91d3b95f47c521bbcc8445247f00f58a58650af5..21a08332c5e08e81c35c0d9d4db343a38983d0d6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1181,7 +1181,6 @@ dependencies = [ "font-kit", "foreign-types", "gpui_macros", - "lazy_static", "log", "metal", "num_cpus", diff --git a/gpui/Cargo.toml b/gpui/Cargo.toml index 0661ef903c14be8e040ecf0a55911e461c0272c4..1eba8612bfa9c2474ca5a0e389bf0824cba6479f 100644 --- a/gpui/Cargo.toml +++ b/gpui/Cargo.toml @@ -9,7 +9,6 @@ async-task = "4.0.3" ctor = "0.1" etagere = "0.2" gpui_macros = {path = "../gpui_macros"} -lazy_static = "1.4" log = "0.4" num_cpus = "1.13" ordered-float = "2.1.1" diff --git a/gpui/src/app.rs b/gpui/src/app.rs index a2f556e6deb12eeff41bc2ec219cb09865683315..efaf410dbb4c59407c776cd5b92fdf6cd826c803 100644 --- a/gpui/src/app.rs +++ b/gpui/src/app.rs @@ -10,7 +10,6 @@ use crate::{ use anyhow::{anyhow, Result}; use async_task::Task; use keymap::MatchResult; -use lazy_static::lazy_static; use parking_lot::{Mutex, RwLock}; use pathfinder_geometry::{rect::RectF, vector::vec2f}; use platform::Event; @@ -2083,15 +2082,6 @@ impl ModelHandle { pub fn condition( &self, ctx: &TestAppContext, - predicate: impl FnMut(&T, &AppContext) -> bool, - ) -> impl Future { - self.condition_with_duration(Duration::from_millis(100), ctx, predicate) - } - - pub fn condition_with_duration( - &self, - duration: Duration, - ctx: &TestAppContext, mut predicate: impl FnMut(&T, &AppContext) -> bool, ) -> impl Future { let (tx, mut rx) = mpsc::channel(1024); @@ -2114,6 +2104,11 @@ impl ModelHandle { let ctx = ctx.weak_self.as_ref().unwrap().upgrade().unwrap(); let handle = self.downgrade(); + let duration = if std::env::var("CI").is_ok() { + Duration::from_secs(2) + } else { + Duration::from_millis(500) + }; async move { timeout(duration, async move { @@ -2293,10 +2288,6 @@ impl ViewHandle { ctx: &TestAppContext, mut predicate: impl FnMut(&T, &AppContext) -> bool, ) -> impl Future { - lazy_static! { - static ref CI: bool = std::env::var("CI").is_ok(); - } - let (tx, mut rx) = mpsc::channel(1024); let mut ctx = ctx.0.borrow_mut(); @@ -2318,8 +2309,8 @@ impl ViewHandle { let ctx = ctx.weak_self.as_ref().unwrap().upgrade().unwrap(); let handle = self.downgrade(); - let duration = if *CI { - Duration::from_secs(1) + let duration = if std::env::var("CI").is_ok() { + Duration::from_secs(2) } else { Duration::from_millis(500) }; diff --git a/zed/src/editor/buffer/mod.rs b/zed/src/editor/buffer/mod.rs index 27044e1dfe2b63b72e904a6e39f7f816e891fcde..8a57201ccff3d5c549f5e9caafd60606806614be 100644 --- a/zed/src/editor/buffer/mod.rs +++ b/zed/src/editor/buffer/mod.rs @@ -3011,9 +3011,7 @@ mod tests { }); fs::remove_file(dir.path().join("file2")).unwrap(); - buffer2 - .condition_with_duration(Duration::from_millis(500), &app, |b, _| b.is_dirty()) - .await; + buffer2.condition(&app, |b, _| b.is_dirty()).await; assert_eq!( *events.borrow(), &[Event::Dirtied, Event::FileHandleChanged] @@ -3038,9 +3036,7 @@ mod tests { events.borrow_mut().clear(); fs::remove_file(dir.path().join("file3")).unwrap(); buffer3 - .condition_with_duration(Duration::from_millis(500), &app, |_, _| { - !events.borrow().is_empty() - }) + .condition(&app, |_, _| !events.borrow().is_empty()) .await; assert_eq!(*events.borrow(), &[Event::FileHandleChanged]); app.read(|ctx| assert!(buffer3.read(ctx).is_dirty())); @@ -3095,9 +3091,7 @@ mod tests { // contents are edited according to the diff between the old and new // file contents. buffer - .condition_with_duration(Duration::from_millis(500), &app, |buffer, _| { - buffer.text() != initial_contents - }) + .condition(&app, |buffer, _| buffer.text() != initial_contents) .await; buffer.update(&mut app, |buffer, _| { @@ -3131,9 +3125,7 @@ mod tests { // Becaues the buffer is modified, it doesn't reload from disk, but is // marked as having a conflict. buffer - .condition_with_duration(Duration::from_millis(500), &app, |buffer, _| { - buffer.has_conflict() - }) + .condition(&app, |buffer, _| buffer.has_conflict()) .await; } diff --git a/zed/src/worktree.rs b/zed/src/worktree.rs index cc9ced3b711f3c9850ed9dfd685891033476d02b..33b23c8d698102f699529183f187466b9fe92c47 100644 --- a/zed/src/worktree.rs +++ b/zed/src/worktree.rs @@ -1276,16 +1276,12 @@ impl WorktreeHandle for ModelHandle { let tree = self.clone(); async move { fs::write(root_path.join(filename), "").unwrap(); - tree.condition_with_duration(Duration::from_secs(5), &app, |tree, _| { - tree.entry_for_path(filename).is_some() - }) - .await; + tree.condition(&app, |tree, _| tree.entry_for_path(filename).is_some()) + .await; fs::remove_file(root_path.join(filename)).unwrap(); - tree.condition_with_duration(Duration::from_secs(5), &app, |tree, _| { - tree.entry_for_path(filename).is_none() - }) - .await; + tree.condition(&app, |tree, _| tree.entry_for_path(filename).is_none()) + .await; app.read(|ctx| tree.read(ctx).scan_complete()).await; }