Created
August 7, 2017 12:52
-
-
Save cyrilchampier/dcf1c663017b17b4d90708494d763c52 to your computer and use it in GitHub Desktop.
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
#[test] | |
fn auto_subdirectory_watch() { | |
let tempdir = TempDir::new("kragle").unwrap(); | |
let path = tempdir.path(); | |
let (tx, rx) = channel(); | |
let mut watcher = watcher(tx.clone(), Duration::from_millis(100)).unwrap(); | |
sleep(Duration::from_millis(100)); | |
watcher.watch(path, RecursiveMode::Recursive).unwrap(); | |
create_dir_all(path.join("sub1").join("sub2")).unwrap(); | |
sleep(Duration::from_millis(200)); | |
let mut file = File::create(path.join("sub1").join("sub2").join("file3")).unwrap(); | |
match rx.recv_timeout(Duration::from_millis(200)) { | |
Ok(DebouncedEvent::Create(ref path)) => assert!(path.ends_with("sub1")), | |
e => panic!("watch error: {:?}", e), | |
} | |
match rx.recv_timeout(Duration::from_millis(200)) { | |
Ok(DebouncedEvent::Create(ref path)) => assert!(path.ends_with("file3")), | |
e => panic!("watch error: {:?}", e), | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment