Skip to content

Commit ee5b0f6

Browse files
committed
Copy watcher test from v4
1 parent 3fc5a31 commit ee5b0f6

File tree

2 files changed

+1902
-2
lines changed

2 files changed

+1902
-2
lines changed

tests/utils/mod.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![allow(dead_code, unused_macros)]
2+
13
use std::{
24
fs,
35
io::Write,
@@ -11,8 +13,8 @@ use std::{
1113
time::{Duration, Instant},
1214
};
1315

14-
use crossbeam_channel::{Receiver, RecvTimeoutError};
15-
use notify::*;
16+
use crossbeam_channel::{Receiver, RecvTimeoutError, Sender};
17+
use notify::{*, poll::PollWatcherConfig};
1618
use tempfile::TempDir;
1719

1820
#[cfg(not(target_os = "windows"))]
@@ -88,6 +90,13 @@ pub fn extract_cookies(events: &[(PathBuf, EventKind, Option<usize>)]) -> Vec<us
8890
cookies
8991
}
9092

93+
pub fn poll_with_delay_ms(tx: Sender<Result<Event>>, delay_ms: u64) -> Result<PollWatcher> {
94+
PollWatcher::with_config(tx, PollWatcherConfig {
95+
poll_interval: Duration::from_millis(delay_ms),
96+
compare_contents: false,
97+
})
98+
}
99+
91100
// Sleep for `duration` in milliseconds
92101
pub fn sleep(duration: u64) {
93102
thread::sleep(Duration::from_millis(duration));

0 commit comments

Comments
 (0)