diff options
Diffstat (limited to 'crates/ra_lsp_server/tests/heavy_tests/support.rs')
-rw-r--r-- | crates/ra_lsp_server/tests/heavy_tests/support.rs | 19 |
1 files changed, 15 insertions, 4 deletions
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 | ) |