Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Try reducing flakiness of fs-event tests by bumping timeout to 4s on CI (#42960)
Antonio Scandurrac1d9dc369c1e
diff --git a/crates/fsevent/src/fsevent.rs b/crates/fsevent/src/fsevent.rsindex e4060f3ae06..0004b752101 100644--- a/crates/fsevent/src/fsevent.rs+++ b/crates/fsevent/src/fsevent.rs@@ -395,19 +395,19 @@ mod tests {thread::spawn(move || stream.run(move |events| tx.send(events.to_vec()).is_ok()));fs::write(path.join("new-file"), "").unwrap();- let events = rx.recv_timeout(Duration::from_secs(2)).unwrap();+ let events = rx.recv_timeout(timeout()).unwrap();let event = events.last().unwrap();assert_eq!(event.path, path.join("new-file"));assert!(event.flags.contains(StreamFlags::ITEM_CREATED));fs::remove_file(path.join("existing-file-5")).unwrap();- let mut events = rx.recv_timeout(Duration::from_secs(2)).unwrap();+ let mut events = rx.recv_timeout(timeout()).unwrap();let mut event = events.last().unwrap();// we see this duplicate about 1/100 test runs.if event.path == path.join("new-file")&& event.flags.contains(StreamFlags::ITEM_CREATED){- events = rx.recv_timeout(Duration::from_secs(2)).unwrap();+ events = rx.recv_timeout(timeout()).unwrap();event = events.last().unwrap();}assert_eq!(event.path, path.join("existing-file-5"));@@ -440,13 +440,13 @@ mod tests {});fs::write(path.join("new-file"), "").unwrap();- let events = rx.recv_timeout(Duration::from_secs(2)).unwrap();+ let events = rx.recv_timeout(timeout()).unwrap();let event = events.last().unwrap();assert_eq!(event.path, path.join("new-file"));assert!(event.flags.contains(StreamFlags::ITEM_CREATED));fs::remove_file(path.join("existing-file-5")).unwrap();- let events = rx.recv_timeout(Duration::from_secs(2)).unwrap();+ let events = rx.recv_timeout(timeout()).unwrap();let event = events.last().unwrap();assert_eq!(event.path, path.join("existing-file-5"));assert!(event.flags.contains(StreamFlags::ITEM_REMOVED));@@ -477,11 +477,11 @@ mod tests {});fs::write(path.join("new-file"), "").unwrap();- assert_eq!(rx.recv_timeout(Duration::from_secs(2)).unwrap(), "running");+ assert_eq!(rx.recv_timeout(timeout()).unwrap(), "running");// Dropping the handle causes `EventStream::run` to return.drop(handle);- assert_eq!(rx.recv_timeout(Duration::from_secs(2)).unwrap(), "stopped");+ assert_eq!(rx.recv_timeout(timeout()).unwrap(), "stopped");}#[test]@@ -500,11 +500,14 @@ mod tests {}fn flush_historical_events() {- let duration = if std::env::var("CI").is_ok() {- Duration::from_secs(2)+ thread::sleep(timeout());+ }++ fn timeout() -> Duration {+ if std::env::var("CI").is_ok() {+ Duration::from_secs(4)} else {Duration::from_millis(500)- };- thread::sleep(duration);+ }}}