Skip to content

Commit

Permalink
fix(watcher): Try removing macos_eat_late_notifications
Browse files Browse the repository at this point in the history
We use a debouncing watcher now, so maybe the problem with late
notifications on macos does not exist anymore?
  • Loading branch information
Profpatsch committed Apr 30, 2024
1 parent be5d5d3 commit fd57d92
Showing 1 changed file with 0 additions and 28 deletions.
28 changes: 0 additions & 28 deletions src/watch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -527,32 +527,6 @@ mod tests {
drop(temp);
}

#[cfg(target_os = "macos")]
fn macos_eat_late_notifications(watcher: &mut Watch) {
// Sometimes a brand new watch will send a CREATE notification
// for a file which was just created, even if the watch was
// created after the file was made.
//
// Our tests want to be very precise about which events are
// received when, so expect these initial events and swallow
// them.
//
// Note, this is racey in the kernel. Otherwise I'd assert
// this is empty.
sleep(WATCHER_TIMEOUT);
watcher.event_rx.try_iter();
}

#[cfg(not(target_os = "macos"))]
fn macos_eat_late_notifications(watcher: &mut Watch) {
// If we're supposedly dealing with a late notification on
// macOS, we'd better not receive any messages on other
// platforms.
//
// If we do receive any notifications, our test is broken.
assert_none_within(watcher, WATCHER_TIMEOUT);
}

#[test]
fn trivial_watch_whole_directory() {
let watcher = Watch::new(&crate::logging::test_logger()).expect("failed creating Watch");
Expand Down Expand Up @@ -603,7 +577,6 @@ mod tests {
.add_to_watch_tx
.send(vec![WatchPathBuf::Recursive(t.join("foo"))])
.unwrap();
macos_eat_late_notifications(&mut watcher);

expect_bash(r#"echo 1 > "$1/foo""#, [t]);
sleep(WATCHER_TIMEOUT);
Expand All @@ -626,7 +599,6 @@ mod tests {
.add_to_watch_tx
.send(vec![WatchPathBuf::Recursive(t.join("foo"))])
.unwrap();
macos_eat_late_notifications(&mut watcher);

// bar is not watched, expect error
expect_bash(r#"echo 1 > "$1/bar""#, [t]);
Expand Down

0 comments on commit fd57d92

Please sign in to comment.