mirror of
https://github.com/priyanshujain/margin-docs.git
synced 2026-10-02 19:17:05 +00:00
Stop a_deleted_root_is_reported_removed giving up on the first quiet window
It broke out of its own deadline loop on the first 900ms recv timeout, so on a runner slower than the laptop it was written on the removal arrived after the test had already decided nothing was coming. Only a dropped sender ends the wait now.
This commit is contained in:
1 parent
f2d3f36a2a
commit
343b18ff57
1 file changed
+8
-2
@@ -13,7 +13,7 @@
|
|||||||
use std::fs;
|
use std::fs;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::sync::atomic::{AtomicU32, Ordering};
|
use std::sync::atomic::{AtomicU32, Ordering};
|
||||||
use std::sync::mpsc::{self, Receiver};
|
use std::sync::mpsc::{self, Receiver, RecvTimeoutError};
|
||||||
use std::time::{Duration, Instant};
|
use std::time::{Duration, Instant};
|
||||||
|
|
||||||
use margin_docs_lib::dto::WatchEvent;
|
use margin_docs_lib::dto::WatchEvent;
|
||||||
@@ -407,7 +407,13 @@ fn a_deleted_root_is_reported_removed() {
|
|||||||
while !removed && Instant::now() < give_up {
|
while !removed && Instant::now() < give_up {
|
||||||
match rx.recv_timeout(QUIET) {
|
match rx.recv_timeout(QUIET) {
|
||||||
Ok(event) => removed = event.path == want && event.kind == "removed",
|
Ok(event) => removed = event.path == want && event.kind == "removed",
|
||||||
Err(_) => break,
|
// A quiet window is not an answer, it is the absence of one. FSEvents coalesces on its
|
||||||
|
// own schedule, so on a loaded machine the first 900ms can pass with nothing in it and
|
||||||
|
// the removal still arrive comfortably inside the 15s deadline. Breaking here gave up
|
||||||
|
// after one such window and made the test a coin flip on any runner slower than this
|
||||||
|
// laptop. Only a dropped sender means no answer is ever coming.
|
||||||
|
Err(RecvTimeoutError::Timeout) => continue,
|
||||||
|
Err(RecvTimeoutError::Disconnected) => break,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assert!(removed, "deleting the root reported nothing");
|
assert!(removed, "deleting the root reported nothing");
|
||||||
|
|||||||
Reference in new issue
Block a user