aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_lsp_server/tests/heavy_tests/support.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-10-31 18:37:32 +0000
committerAleksey Kladov <[email protected]>2018-10-31 18:37:40 +0000
commit64ce895ef0beea75e9ecfcdf5b4e226a8a6336d8 (patch)
treeaf07f03610a2ef1f8a49d773170146d0c1774750 /crates/ra_lsp_server/tests/heavy_tests/support.rs
parentb58ca6b1a68471f6944893b94f09cd56dc28f837 (diff)
extract fixture parsing
Diffstat (limited to 'crates/ra_lsp_server/tests/heavy_tests/support.rs')
-rw-r--r--crates/ra_lsp_server/tests/heavy_tests/support.rs29
1 files changed, 7 insertions, 22 deletions
diff --git a/crates/ra_lsp_server/tests/heavy_tests/support.rs b/crates/ra_lsp_server/tests/heavy_tests/support.rs
index 004d7e8ad..b90d21135 100644
--- a/crates/ra_lsp_server/tests/heavy_tests/support.rs
+++ b/crates/ra_lsp_server/tests/heavy_tests/support.rs
@@ -17,6 +17,7 @@ use languageserver_types::{
17use serde::Serialize; 17use serde::Serialize;
18use serde_json::{from_str, to_string_pretty, Value}; 18use serde_json::{from_str, to_string_pretty, Value};
19use tempdir::TempDir; 19use tempdir::TempDir;
20use test_utils::parse_fixture;
20 21
21use ra_lsp_server::{ 22use ra_lsp_server::{
22 main_loop, req, 23 main_loop, req,
@@ -28,30 +29,14 @@ pub fn project(fixture: &str) -> Server {
28 INIT.call_once(|| Logger::with_env_or_str(crate::LOG).start().unwrap()); 29 INIT.call_once(|| Logger::with_env_or_str(crate::LOG).start().unwrap());
29 30
30 let tmp_dir = TempDir::new("test-project").unwrap(); 31 let tmp_dir = TempDir::new("test-project").unwrap();
31 let mut buf = String::new();
32 let mut file_name = None;
33 let mut paths = vec![]; 32 let mut paths = vec![];
34 macro_rules! flush { 33
35 () => { 34 for entry in parse_fixture(fixture) {
36 if let Some(file_name) = file_name { 35 let path = tmp_dir.path().join(entry.meta);
37 let path = tmp_dir.path().join(file_name); 36 fs::create_dir_all(path.parent().unwrap()).unwrap();
38 fs::create_dir_all(path.parent().unwrap()).unwrap(); 37 fs::write(path.as_path(), entry.text.as_bytes()).unwrap();
39 fs::write(path.as_path(), buf.as_bytes()).unwrap(); 38 paths.push((path, entry.text));
40 paths.push((path, buf.clone()));
41 }
42 };
43 };
44 for line in fixture.lines() {
45 if line.starts_with("//-") {
46 flush!();
47 buf.clear();
48 file_name = Some(line["//-".len()..].trim());
49 continue;
50 }
51 buf.push_str(line);
52 buf.push('\n');
53 } 39 }
54 flush!();
55 Server::new(tmp_dir, paths) 40 Server::new(tmp_dir, paths)
56} 41}
57 42