diff options
Diffstat (limited to 'crates/ra_vfs/tests/vfs.rs')
-rw-r--r-- | crates/ra_vfs/tests/vfs.rs | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/crates/ra_vfs/tests/vfs.rs b/crates/ra_vfs/tests/vfs.rs index 8562c56b9..357e1c775 100644 --- a/crates/ra_vfs/tests/vfs.rs +++ b/crates/ra_vfs/tests/vfs.rs | |||
@@ -1,12 +1,16 @@ | |||
1 | use std::{collections::HashSet, fs}; | 1 | use std::{collections::HashSet, fs, time::Duration}; |
2 | 2 | ||
3 | use flexi_logger::Logger; | 3 | // use flexi_logger::Logger; |
4 | use crossbeam_channel::RecvTimeoutError; | ||
4 | use ra_vfs::{Vfs, VfsChange}; | 5 | use ra_vfs::{Vfs, VfsChange}; |
5 | use tempfile::tempdir; | 6 | use tempfile::tempdir; |
6 | 7 | ||
7 | fn process_tasks(vfs: &mut Vfs, num_tasks: u32) { | 8 | fn process_tasks(vfs: &mut Vfs, num_tasks: u32) { |
8 | for _ in 0..num_tasks { | 9 | for _ in 0..num_tasks { |
9 | let task = vfs.task_receiver().recv().unwrap(); | 10 | let task = vfs |
11 | .task_receiver() | ||
12 | .recv_timeout(Duration::from_secs(3)) | ||
13 | .unwrap(); | ||
10 | log::debug!("{:?}", task); | 14 | log::debug!("{:?}", task); |
11 | vfs.handle_task(task); | 15 | vfs.handle_task(task); |
12 | } | 16 | } |
@@ -14,7 +18,7 @@ fn process_tasks(vfs: &mut Vfs, num_tasks: u32) { | |||
14 | 18 | ||
15 | macro_rules! assert_match { | 19 | macro_rules! assert_match { |
16 | ($x:expr, $pat:pat) => { | 20 | ($x:expr, $pat:pat) => { |
17 | assert_match!($x, $pat, assert!(true)) | 21 | assert_match!($x, $pat, ()) |
18 | }; | 22 | }; |
19 | ($x:expr, $pat:pat, $assert:expr) => { | 23 | ($x:expr, $pat:pat, $assert:expr) => { |
20 | match $x { | 24 | match $x { |
@@ -26,7 +30,7 @@ macro_rules! assert_match { | |||
26 | 30 | ||
27 | #[test] | 31 | #[test] |
28 | fn test_vfs_works() -> std::io::Result<()> { | 32 | fn test_vfs_works() -> std::io::Result<()> { |
29 | Logger::with_str("vfs=debug,ra_vfs=debug").start().unwrap(); | 33 | // Logger::with_str("vfs=debug,ra_vfs=debug").start().unwrap(); |
30 | 34 | ||
31 | let files = [ | 35 | let files = [ |
32 | ("a/foo.rs", "hello"), | 36 | ("a/foo.rs", "hello"), |
@@ -166,8 +170,8 @@ fn test_vfs_works() -> std::io::Result<()> { | |||
166 | fs::write(&dir.path().join("a/target/new.rs"), "ignore me").unwrap(); | 170 | fs::write(&dir.path().join("a/target/new.rs"), "ignore me").unwrap(); |
167 | 171 | ||
168 | assert_match!( | 172 | assert_match!( |
169 | vfs.task_receiver().try_recv(), | 173 | vfs.task_receiver().recv_timeout(Duration::from_millis(300)), // slightly more than watcher debounce delay |
170 | Err(crossbeam_channel::TryRecvError::Empty) | 174 | Err(RecvTimeoutError::Timeout) |
171 | ); | 175 | ); |
172 | 176 | ||
173 | vfs.shutdown().unwrap(); | 177 | vfs.shutdown().unwrap(); |