diff options
author | Aleksey Kladov <[email protected]> | 2019-08-19 13:41:18 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-08-19 13:41:18 +0100 |
commit | 7cd9b1dd7a91fb3b1e400fd4b47333c9699381f7 (patch) | |
tree | 2e9b1fc0839fba1a55d1c95a3ab601bdcec7d0d9 /crates/ra_lsp_server/tests | |
parent | cef90ce45ee9954e864933450953f5eb83429f01 (diff) |
don't load sysroot in most heavy tests
Diffstat (limited to 'crates/ra_lsp_server/tests')
-rw-r--r-- | crates/ra_lsp_server/tests/heavy_tests/main.rs | 13 | ||||
-rw-r--r-- | crates/ra_lsp_server/tests/heavy_tests/support.rs | 19 |
2 files changed, 24 insertions, 8 deletions
diff --git a/crates/ra_lsp_server/tests/heavy_tests/main.rs b/crates/ra_lsp_server/tests/heavy_tests/main.rs index 451be32a8..de3bd5bc5 100644 --- a/crates/ra_lsp_server/tests/heavy_tests/main.rs +++ b/crates/ra_lsp_server/tests/heavy_tests/main.rs | |||
@@ -22,7 +22,7 @@ const PROFILE: &'static str = ""; | |||
22 | #[test] | 22 | #[test] |
23 | fn completes_items_from_standard_library() { | 23 | fn completes_items_from_standard_library() { |
24 | let project_start = Instant::now(); | 24 | let project_start = Instant::now(); |
25 | let server = project( | 25 | let server = Project::with_fixture( |
26 | r#" | 26 | r#" |
27 | //- Cargo.toml | 27 | //- Cargo.toml |
28 | [package] | 28 | [package] |
@@ -32,7 +32,9 @@ version = "0.0.0" | |||
32 | //- src/lib.rs | 32 | //- src/lib.rs |
33 | use std::collections::Spam; | 33 | use std::collections::Spam; |
34 | "#, | 34 | "#, |
35 | ); | 35 | ) |
36 | .with_sysroot(true) | ||
37 | .server(); | ||
36 | server.wait_until_workspace_is_loaded(); | 38 | server.wait_until_workspace_is_loaded(); |
37 | eprintln!("loading took {:?}", project_start.elapsed()); | 39 | eprintln!("loading took {:?}", project_start.elapsed()); |
38 | let completion_start = Instant::now(); | 40 | let completion_start = Instant::now(); |
@@ -349,7 +351,7 @@ fn main() {{}} | |||
349 | fn diagnostics_dont_block_typing() { | 351 | fn diagnostics_dont_block_typing() { |
350 | let librs: String = (0..10).map(|i| format!("mod m{};", i)).collect(); | 352 | let librs: String = (0..10).map(|i| format!("mod m{};", i)).collect(); |
351 | let libs: String = (0..10).map(|i| format!("//- src/m{}.rs\nfn foo() {{}}\n\n", i)).collect(); | 353 | let libs: String = (0..10).map(|i| format!("//- src/m{}.rs\nfn foo() {{}}\n\n", i)).collect(); |
352 | let server = project(&format!( | 354 | let server = Project::with_fixture(&format!( |
353 | r#" | 355 | r#" |
354 | //- Cargo.toml | 356 | //- Cargo.toml |
355 | [package] | 357 | [package] |
@@ -364,7 +366,10 @@ version = "0.0.0" | |||
364 | fn main() {{}} | 366 | fn main() {{}} |
365 | "#, | 367 | "#, |
366 | librs, libs | 368 | librs, libs |
367 | )); | 369 | )) |
370 | .with_sysroot(true) | ||
371 | .server(); | ||
372 | |||
368 | server.wait_until_workspace_is_loaded(); | 373 | server.wait_until_workspace_is_loaded(); |
369 | for i in 0..10 { | 374 | for i in 0..10 { |
370 | server.notification::<DidOpenTextDocument>(DidOpenTextDocumentParams { | 375 | server.notification::<DidOpenTextDocument>(DidOpenTextDocumentParams { |
diff --git a/crates/ra_lsp_server/tests/heavy_tests/support.rs b/crates/ra_lsp_server/tests/heavy_tests/support.rs index ba8ee8b06..055c8fff2 100644 --- a/crates/ra_lsp_server/tests/heavy_tests/support.rs +++ b/crates/ra_lsp_server/tests/heavy_tests/support.rs | |||
@@ -26,13 +26,14 @@ use ra_lsp_server::{main_loop, req, ServerConfig}; | |||
26 | 26 | ||
27 | pub struct Project<'a> { | 27 | pub struct Project<'a> { |
28 | fixture: &'a str, | 28 | fixture: &'a str, |
29 | with_sysroot: bool, | ||
29 | tmp_dir: Option<TempDir>, | 30 | tmp_dir: Option<TempDir>, |
30 | roots: Vec<PathBuf>, | 31 | roots: Vec<PathBuf>, |
31 | } | 32 | } |
32 | 33 | ||
33 | impl<'a> Project<'a> { | 34 | impl<'a> Project<'a> { |
34 | pub fn with_fixture(fixture: &str) -> Project { | 35 | pub fn with_fixture(fixture: &str) -> Project { |
35 | Project { fixture, tmp_dir: None, roots: vec![] } | 36 | Project { fixture, tmp_dir: None, roots: vec![], with_sysroot: false } |
36 | } | 37 | } |
37 | 38 | ||
38 | pub fn tmp_dir(mut self, tmp_dir: TempDir) -> Project<'a> { | 39 | pub fn tmp_dir(mut self, tmp_dir: TempDir) -> Project<'a> { |
@@ -45,6 +46,11 @@ impl<'a> Project<'a> { | |||
45 | self | 46 | self |
46 | } | 47 | } |
47 | 48 | ||
49 | pub fn with_sysroot(mut self, sysroot: bool) -> Project<'a> { | ||
50 | self.with_sysroot = sysroot; | ||
51 | self | ||
52 | } | ||
53 | |||
48 | pub fn server(self) -> Server { | 54 | pub fn server(self) -> Server { |
49 | let tmp_dir = self.tmp_dir.unwrap_or_else(|| TempDir::new().unwrap()); | 55 | let tmp_dir = self.tmp_dir.unwrap_or_else(|| TempDir::new().unwrap()); |
50 | static INIT: Once = Once::new(); | 56 | static INIT: Once = Once::new(); |
@@ -68,7 +74,7 @@ impl<'a> Project<'a> { | |||
68 | 74 | ||
69 | let roots = self.roots.into_iter().map(|root| tmp_dir.path().join(root)).collect(); | 75 | let roots = self.roots.into_iter().map(|root| tmp_dir.path().join(root)).collect(); |
70 | 76 | ||
71 | Server::new(tmp_dir, roots, paths) | 77 | Server::new(tmp_dir, self.with_sysroot, roots, paths) |
72 | } | 78 | } |
73 | } | 79 | } |
74 | 80 | ||
@@ -84,7 +90,12 @@ pub struct Server { | |||
84 | } | 90 | } |
85 | 91 | ||
86 | impl Server { | 92 | impl Server { |
87 | fn new(dir: TempDir, roots: Vec<PathBuf>, files: Vec<(PathBuf, String)>) -> Server { | 93 | fn new( |
94 | dir: TempDir, | ||
95 | with_sysroot: bool, | ||
96 | roots: Vec<PathBuf>, | ||
97 | files: Vec<(PathBuf, String)>, | ||
98 | ) -> Server { | ||
88 | let path = dir.path().to_path_buf(); | 99 | let path = dir.path().to_path_buf(); |
89 | 100 | ||
90 | let roots = if roots.is_empty() { vec![path] } else { roots }; | 101 | let roots = if roots.is_empty() { vec![path] } else { roots }; |
@@ -107,7 +118,7 @@ impl Server { | |||
107 | window: None, | 118 | window: None, |
108 | experimental: None, | 119 | experimental: None, |
109 | }, | 120 | }, |
110 | ServerConfig::default(), | 121 | ServerConfig { with_sysroot, ..ServerConfig::default() }, |
111 | &msg_receiver, | 122 | &msg_receiver, |
112 | &msg_sender, | 123 | &msg_sender, |
113 | ) | 124 | ) |