Skip to content

Commit 6c635dc

Browse files
authored
test: wait a short period before checking whether no events were received (#29)
So that the assertion doesn't miss events that happens after a short period.
1 parent c328c67 commit 6c635dc

File tree

5 files changed

+14
-10
lines changed

5 files changed

+14
-10
lines changed

notify/src/fsevent.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -885,8 +885,7 @@ mod tests {
885885

886886
std::fs::write(&file, "").expect("write");
887887

888-
thread::sleep(Duration::from_millis(10));
889-
// rx.ensure_empty(); // TODO: should unwatch
888+
// rx.ensure_empty_with_wait(); // TODO: should unwatch
890889
}
891890

892891
#[test]
@@ -1013,8 +1012,7 @@ mod tests {
10131012

10141013
std::fs::create_dir(&path).expect("create_dir2");
10151014

1016-
thread::sleep(Duration::from_millis(10));
1017-
// rx.ensure_empty(); // TODO: should unwatch
1015+
// rx.ensure_empty_with_wait(); // TODO: should unwatch
10181016
}
10191017

10201018
#[test]

notify/src/inotify.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1302,7 +1302,7 @@ mod tests {
13021302

13031303
std::fs::write(&file, "").expect("write");
13041304

1305-
rx.ensure_empty();
1305+
rx.ensure_empty_with_wait();
13061306
}
13071307

13081308
#[test]
@@ -1558,7 +1558,7 @@ mod tests {
15581558

15591559
std::fs::create_dir(&path).expect("create_dir2");
15601560

1561-
rx.ensure_empty();
1561+
rx.ensure_empty_with_wait();
15621562
}
15631563

15641564
#[test]

notify/src/kqueue.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1025,7 +1025,7 @@ mod tests {
10251025

10261026
std::fs::write(&file, "").expect("write");
10271027

1028-
rx.ensure_empty();
1028+
rx.ensure_empty_with_wait();
10291029
}
10301030

10311031
#[test]
@@ -1211,7 +1211,7 @@ mod tests {
12111211

12121212
std::fs::create_dir(&path).expect("create_dir2");
12131213

1214-
rx.ensure_empty();
1214+
rx.ensure_empty_with_wait();
12151215
}
12161216

12171217
#[test]

notify/src/test.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,12 @@ impl Receiver {
156156
}
157157
}
158158

159+
/// Ensures, that the receiver part is empty. It waits for a short period and then checks the channel
160+
pub fn ensure_empty_with_wait(&mut self) {
161+
thread::sleep(Duration::from_millis(10));
162+
self.ensure_empty();
163+
}
164+
159165
/// see [`sleep_until`].
160166
///
161167
/// it uses timeout from [`Self::timeout`]

notify/src/windows.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,7 +1053,7 @@ pub mod tests {
10531053

10541054
// std::fs::write(&file, "").expect("write");
10551055

1056-
// rx.ensure_empty();
1056+
// rx.ensure_empty_with_wait();
10571057
}
10581058

10591059
#[test]
@@ -1284,7 +1284,7 @@ pub mod tests {
12841284

12851285
std::fs::create_dir(&path).expect("create_dir2");
12861286

1287-
rx.ensure_empty();
1287+
rx.ensure_empty_with_wait();
12881288
}
12891289

12901290
#[test]

0 commit comments

Comments
 (0)