From 7cd9b1dd7a91fb3b1e400fd4b47333c9699381f7 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 19 Aug 2019 15:41:18 +0300 Subject: don't load sysroot in most heavy tests --- crates/ra_lsp_server/tests/heavy_tests/main.rs | 13 +++++++++---- crates/ra_lsp_server/tests/heavy_tests/support.rs | 19 +++++++++++++++---- 2 files changed, 24 insertions(+), 8 deletions(-) (limited to 'crates/ra_lsp_server/tests/heavy_tests') 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 = ""; #[test] fn completes_items_from_standard_library() { let project_start = Instant::now(); - let server = project( + let server = Project::with_fixture( r#" //- Cargo.toml [package] @@ -32,7 +32,9 @@ version = "0.0.0" //- src/lib.rs use std::collections::Spam; "#, - ); + ) + .with_sysroot(true) + .server(); server.wait_until_workspace_is_loaded(); eprintln!("loading took {:?}", project_start.elapsed()); let completion_start = Instant::now(); @@ -349,7 +351,7 @@ fn main() {{}} fn diagnostics_dont_block_typing() { let librs: String = (0..10).map(|i| format!("mod m{};", i)).collect(); let libs: String = (0..10).map(|i| format!("//- src/m{}.rs\nfn foo() {{}}\n\n", i)).collect(); - let server = project(&format!( + let server = Project::with_fixture(&format!( r#" //- Cargo.toml [package] @@ -364,7 +366,10 @@ version = "0.0.0" fn main() {{}} "#, librs, libs - )); + )) + .with_sysroot(true) + .server(); + server.wait_until_workspace_is_loaded(); for i in 0..10 { server.notification::(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}; pub struct Project<'a> { fixture: &'a str, + with_sysroot: bool, tmp_dir: Option, roots: Vec, } impl<'a> Project<'a> { pub fn with_fixture(fixture: &str) -> Project { - Project { fixture, tmp_dir: None, roots: vec![] } + Project { fixture, tmp_dir: None, roots: vec![], with_sysroot: false } } pub fn tmp_dir(mut self, tmp_dir: TempDir) -> Project<'a> { @@ -45,6 +46,11 @@ impl<'a> Project<'a> { self } + pub fn with_sysroot(mut self, sysroot: bool) -> Project<'a> { + self.with_sysroot = sysroot; + self + } + pub fn server(self) -> Server { let tmp_dir = self.tmp_dir.unwrap_or_else(|| TempDir::new().unwrap()); static INIT: Once = Once::new(); @@ -68,7 +74,7 @@ impl<'a> Project<'a> { let roots = self.roots.into_iter().map(|root| tmp_dir.path().join(root)).collect(); - Server::new(tmp_dir, roots, paths) + Server::new(tmp_dir, self.with_sysroot, roots, paths) } } @@ -84,7 +90,12 @@ pub struct Server { } impl Server { - fn new(dir: TempDir, roots: Vec, files: Vec<(PathBuf, String)>) -> Server { + fn new( + dir: TempDir, + with_sysroot: bool, + roots: Vec, + files: Vec<(PathBuf, String)>, + ) -> Server { let path = dir.path().to_path_buf(); let roots = if roots.is_empty() { vec![path] } else { roots }; @@ -107,7 +118,7 @@ impl Server { window: None, experimental: None, }, - ServerConfig::default(), + ServerConfig { with_sysroot, ..ServerConfig::default() }, &msg_receiver, &msg_sender, ) -- cgit v1.2.3