aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_vfs/tests
diff options
context:
space:
mode:
authorBernardo <[email protected]>2019-01-25 21:13:55 +0000
committerAleksey Kladov <[email protected]>2019-01-26 08:46:37 +0000
commit410a3ae6e847b59f9930ce4d6bf9f3c5f1d72167 (patch)
tree5717d124c71de13412f61a8584b119da378828ae /crates/ra_vfs/tests
parentd63e1cebff771621b90bdce25ac013eecb415e1e (diff)
use entry file_type, improve test
Diffstat (limited to 'crates/ra_vfs/tests')
-rw-r--r--crates/ra_vfs/tests/vfs.rs18
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 @@
1use std::{collections::HashSet, fs}; 1use std::{collections::HashSet, fs, time::Duration};
2 2
3use flexi_logger::Logger; 3// use flexi_logger::Logger;
4use crossbeam_channel::RecvTimeoutError;
4use ra_vfs::{Vfs, VfsChange}; 5use ra_vfs::{Vfs, VfsChange};
5use tempfile::tempdir; 6use tempfile::tempdir;
6 7
7fn process_tasks(vfs: &mut Vfs, num_tasks: u32) { 8fn 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
15macro_rules! assert_match { 19macro_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]
28fn test_vfs_works() -> std::io::Result<()> { 32fn 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();