aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_vfs/tests/vfs.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_vfs/tests/vfs.rs')
-rw-r--r--crates/ra_vfs/tests/vfs.rs23
1 files changed, 12 insertions, 11 deletions
diff --git a/crates/ra_vfs/tests/vfs.rs b/crates/ra_vfs/tests/vfs.rs
index 87fb5a092..8266a0bd5 100644
--- a/crates/ra_vfs/tests/vfs.rs
+++ b/crates/ra_vfs/tests/vfs.rs
@@ -62,23 +62,24 @@ fn test_vfs_works() -> std::io::Result<()> {
62 } 62 }
63 63
64 fs::write(&dir.path().join("a/b/baz.rs"), "quux").unwrap(); 64 fs::write(&dir.path().join("a/b/baz.rs"), "quux").unwrap();
65 process_tasks(&mut vfs, 1); 65 // 2 tasks per watcher change, first for HandleChange then for LoadChange
66 process_tasks(&mut vfs, 2);
66 match vfs.commit_changes().as_slice() { 67 match vfs.commit_changes().as_slice() {
67 [VfsChange::ChangeFile { text, .. }] => assert_eq!(text.as_str(), "quux"), 68 [VfsChange::ChangeFile { text, .. }] => assert_eq!(text.as_str(), "quux"),
68 _ => panic!("unexpected changes"), 69 xs => panic!("unexpected changes {:?}", xs),
69 } 70 }
70 71
71 vfs.change_file_overlay(&dir.path().join("a/b/baz.rs"), "m".to_string()); 72 vfs.change_file_overlay(&dir.path().join("a/b/baz.rs"), "m".to_string());
72 match vfs.commit_changes().as_slice() { 73 match vfs.commit_changes().as_slice() {
73 [VfsChange::ChangeFile { text, .. }] => assert_eq!(text.as_str(), "m"), 74 [VfsChange::ChangeFile { text, .. }] => assert_eq!(text.as_str(), "m"),
74 _ => panic!("unexpected changes"), 75 xs => panic!("unexpected changes {:?}", xs),
75 } 76 }
76 77
77 // removing overlay restores data on disk 78 // removing overlay restores data on disk
78 vfs.remove_file_overlay(&dir.path().join("a/b/baz.rs")); 79 vfs.remove_file_overlay(&dir.path().join("a/b/baz.rs"));
79 match vfs.commit_changes().as_slice() { 80 match vfs.commit_changes().as_slice() {
80 [VfsChange::ChangeFile { text, .. }] => assert_eq!(text.as_str(), "quux"), 81 [VfsChange::ChangeFile { text, .. }] => assert_eq!(text.as_str(), "quux"),
81 _ => panic!("unexpected changes"), 82 xs => panic!("unexpected changes {:?}", xs),
82 } 83 }
83 84
84 vfs.add_file_overlay(&dir.path().join("a/b/spam.rs"), "spam".to_string()); 85 vfs.add_file_overlay(&dir.path().join("a/b/spam.rs"), "spam".to_string());
@@ -87,27 +88,27 @@ fn test_vfs_works() -> std::io::Result<()> {
87 assert_eq!(text.as_str(), "spam"); 88 assert_eq!(text.as_str(), "spam");
88 assert_eq!(path, "spam.rs"); 89 assert_eq!(path, "spam.rs");
89 } 90 }
90 _ => panic!("unexpected changes"), 91 xs => panic!("unexpected changes {:?}", xs),
91 } 92 }
92 93
93 vfs.remove_file_overlay(&dir.path().join("a/b/spam.rs")); 94 vfs.remove_file_overlay(&dir.path().join("a/b/spam.rs"));
94 match vfs.commit_changes().as_slice() { 95 match vfs.commit_changes().as_slice() {
95 [VfsChange::RemoveFile { path, .. }] => assert_eq!(path, "spam.rs"), 96 [VfsChange::RemoveFile { path, .. }] => assert_eq!(path, "spam.rs"),
96 _ => panic!("unexpected changes"), 97 xs => panic!("unexpected changes {:?}", xs),
97 } 98 }
98 99
99 fs::write(&dir.path().join("a/new.rs"), "new hello").unwrap(); 100 fs::write(&dir.path().join("a/new.rs"), "new hello").unwrap();
100 process_tasks(&mut vfs, 1); 101 process_tasks(&mut vfs, 2);
101 match vfs.commit_changes().as_slice() { 102 match vfs.commit_changes().as_slice() {
102 [VfsChange::AddFile { text, path, .. }] => { 103 [VfsChange::AddFile { text, path, .. }] => {
103 assert_eq!(text.as_str(), "new hello"); 104 assert_eq!(text.as_str(), "new hello");
104 assert_eq!(path, "new.rs"); 105 assert_eq!(path, "new.rs");
105 } 106 }
106 _ => panic!("unexpected changes"), 107 xs => panic!("unexpected changes {:?}", xs),
107 } 108 }
108 109
109 fs::rename(&dir.path().join("a/new.rs"), &dir.path().join("a/new1.rs")).unwrap(); 110 fs::rename(&dir.path().join("a/new.rs"), &dir.path().join("a/new1.rs")).unwrap();
110 process_tasks(&mut vfs, 2); 111 process_tasks(&mut vfs, 4);
111 match vfs.commit_changes().as_slice() { 112 match vfs.commit_changes().as_slice() {
112 [VfsChange::RemoveFile { 113 [VfsChange::RemoveFile {
113 path: removed_path, .. 114 path: removed_path, ..
@@ -124,10 +125,10 @@ fn test_vfs_works() -> std::io::Result<()> {
124 } 125 }
125 126
126 fs::remove_file(&dir.path().join("a/new1.rs")).unwrap(); 127 fs::remove_file(&dir.path().join("a/new1.rs")).unwrap();
127 process_tasks(&mut vfs, 1); 128 process_tasks(&mut vfs, 2);
128 match vfs.commit_changes().as_slice() { 129 match vfs.commit_changes().as_slice() {
129 [VfsChange::RemoveFile { path, .. }] => assert_eq!(path, "new1.rs"), 130 [VfsChange::RemoveFile { path, .. }] => assert_eq!(path, "new1.rs"),
130 _ => panic!("unexpected changes"), 131 xs => panic!("unexpected changes {:?}", xs),
131 } 132 }
132 133
133 match vfs.task_receiver().try_recv() { 134 match vfs.task_receiver().try_recv() {