-
Notifications
You must be signed in to change notification settings - Fork 229
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(based on commit 86421e5) Signed-off-by: Aron Heinecke <[email protected]>
- Loading branch information
Showing
3 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
use std::{env, fs, thread, time::Duration}; | ||
|
||
extern crate notify; | ||
use notify::{RecommendedWatcher, RecursiveMode, Watcher}; | ||
use std::sync::mpsc; | ||
|
||
/// Test for <https://github.com/notify-rs/notify/issues/301>. | ||
/// Note: This test will fail if your temp directory is not writable. | ||
#[test] | ||
fn test_race_with_remove_dir() { | ||
let tmpdir = env::temp_dir().join(".tmprPcUcB"); | ||
fs::create_dir_all(&tmpdir).unwrap(); | ||
|
||
{ | ||
let tmpdir = tmpdir.clone(); | ||
let (tx, rx) = mpsc::channel(); | ||
thread::spawn(move || { | ||
let mut watcher = RecommendedWatcher::new_raw(tx) | ||
.unwrap(); | ||
|
||
watcher.watch(tmpdir, RecursiveMode::NonRecursive).unwrap(); | ||
}); | ||
thread::spawn(move || { | ||
for msg in rx { | ||
eprintln!("received event: {:?}", msg); | ||
} | ||
}); | ||
} | ||
|
||
let subdir = tmpdir.join("146d921d.tmp"); | ||
fs::create_dir_all(&subdir).unwrap(); | ||
fs::remove_dir_all(&tmpdir).unwrap(); | ||
thread::sleep(Duration::from_secs(1)); | ||
} |