diff options
Diffstat (limited to 'crates/ra_lsp_server/tests/heavy_tests')
-rw-r--r-- | crates/ra_lsp_server/tests/heavy_tests/main.rs | 118 | ||||
-rw-r--r-- | crates/ra_lsp_server/tests/heavy_tests/support.rs | 3 |
2 files changed, 117 insertions, 4 deletions
diff --git a/crates/ra_lsp_server/tests/heavy_tests/main.rs b/crates/ra_lsp_server/tests/heavy_tests/main.rs index 2ba82ab05..dff63a12d 100644 --- a/crates/ra_lsp_server/tests/heavy_tests/main.rs +++ b/crates/ra_lsp_server/tests/heavy_tests/main.rs | |||
@@ -4,7 +4,8 @@ use std::{collections::HashMap, time::Instant}; | |||
4 | 4 | ||
5 | use lsp_types::{ | 5 | use lsp_types::{ |
6 | CodeActionContext, DidOpenTextDocumentParams, DocumentFormattingParams, FormattingOptions, | 6 | CodeActionContext, DidOpenTextDocumentParams, DocumentFormattingParams, FormattingOptions, |
7 | Position, Range, TextDocumentItem, TextDocumentPositionParams, | 7 | PartialResultParams, Position, Range, TextDocumentItem, TextDocumentPositionParams, |
8 | WorkDoneProgressParams, | ||
8 | }; | 9 | }; |
9 | use ra_lsp_server::req::{ | 10 | use ra_lsp_server::req::{ |
10 | CodeActionParams, CodeActionRequest, Completion, CompletionParams, DidOpenTextDocument, | 11 | CodeActionParams, CodeActionRequest, Completion, CompletionParams, DidOpenTextDocument, |
@@ -12,15 +13,19 @@ use ra_lsp_server::req::{ | |||
12 | }; | 13 | }; |
13 | use serde_json::json; | 14 | use serde_json::json; |
14 | use tempfile::TempDir; | 15 | use tempfile::TempDir; |
16 | use test_utils::skip_slow_tests; | ||
15 | 17 | ||
16 | use crate::support::{project, Project}; | 18 | use crate::support::{project, Project}; |
17 | 19 | ||
18 | const LOG: &'static str = ""; | ||
19 | const PROFILE: &'static str = ""; | 20 | const PROFILE: &'static str = ""; |
20 | // const PROFILE: &'static str = "*@3>100"; | 21 | // const PROFILE: &'static str = "*@3>100"; |
21 | 22 | ||
22 | #[test] | 23 | #[test] |
23 | fn completes_items_from_standard_library() { | 24 | fn completes_items_from_standard_library() { |
25 | if skip_slow_tests() { | ||
26 | return; | ||
27 | } | ||
28 | |||
24 | let project_start = Instant::now(); | 29 | let project_start = Instant::now(); |
25 | let server = Project::with_fixture( | 30 | let server = Project::with_fixture( |
26 | r#" | 31 | r#" |
@@ -44,6 +49,8 @@ use std::collections::Spam; | |||
44 | Position::new(0, 23), | 49 | Position::new(0, 23), |
45 | ), | 50 | ), |
46 | context: None, | 51 | context: None, |
52 | partial_result_params: PartialResultParams::default(), | ||
53 | work_done_progress_params: WorkDoneProgressParams::default(), | ||
47 | }); | 54 | }); |
48 | assert!(format!("{}", res).contains("HashMap")); | 55 | assert!(format!("{}", res).contains("HashMap")); |
49 | eprintln!("completion took {:?}", completion_start.elapsed()); | 56 | eprintln!("completion took {:?}", completion_start.elapsed()); |
@@ -51,6 +58,10 @@ use std::collections::Spam; | |||
51 | 58 | ||
52 | #[test] | 59 | #[test] |
53 | fn test_runnables_no_project() { | 60 | fn test_runnables_no_project() { |
61 | if skip_slow_tests() { | ||
62 | return; | ||
63 | } | ||
64 | |||
54 | let server = project( | 65 | let server = project( |
55 | r" | 66 | r" |
56 | //- lib.rs | 67 | //- lib.rs |
@@ -100,6 +111,10 @@ fn foo() { | |||
100 | 111 | ||
101 | #[test] | 112 | #[test] |
102 | fn test_runnables_project() { | 113 | fn test_runnables_project() { |
114 | if skip_slow_tests() { | ||
115 | return; | ||
116 | } | ||
117 | |||
103 | let code = r#" | 118 | let code = r#" |
104 | //- foo/Cargo.toml | 119 | //- foo/Cargo.toml |
105 | [package] | 120 | [package] |
@@ -171,8 +186,13 @@ fn main() {} | |||
171 | 186 | ||
172 | #[test] | 187 | #[test] |
173 | fn test_format_document() { | 188 | fn test_format_document() { |
189 | if skip_slow_tests() { | ||
190 | return; | ||
191 | } | ||
192 | |||
174 | let server = project( | 193 | let server = project( |
175 | r#" | 194 | r#" |
195 | //- Cargo.toml | ||
176 | [package] | 196 | [package] |
177 | name = "foo" | 197 | name = "foo" |
178 | version = "0.0.0" | 198 | version = "0.0.0" |
@@ -194,8 +214,12 @@ pub use std::collections::HashMap; | |||
194 | options: FormattingOptions { | 214 | options: FormattingOptions { |
195 | tab_size: 4, | 215 | tab_size: 4, |
196 | insert_spaces: false, | 216 | insert_spaces: false, |
217 | insert_final_newline: None, | ||
218 | trim_final_newlines: None, | ||
219 | trim_trailing_whitespace: None, | ||
197 | properties: HashMap::new(), | 220 | properties: HashMap::new(), |
198 | }, | 221 | }, |
222 | work_done_progress_params: WorkDoneProgressParams::default(), | ||
199 | }, | 223 | }, |
200 | json!([ | 224 | json!([ |
201 | { | 225 | { |
@@ -221,7 +245,77 @@ pub use std::collections::HashMap; | |||
221 | } | 245 | } |
222 | 246 | ||
223 | #[test] | 247 | #[test] |
248 | fn test_format_document_2018() { | ||
249 | if skip_slow_tests() { | ||
250 | return; | ||
251 | } | ||
252 | |||
253 | let server = project( | ||
254 | r#" | ||
255 | //- Cargo.toml | ||
256 | [package] | ||
257 | name = "foo" | ||
258 | version = "0.0.0" | ||
259 | edition = "2018" | ||
260 | |||
261 | //- src/lib.rs | ||
262 | mod bar; | ||
263 | |||
264 | async fn test() { | ||
265 | } | ||
266 | |||
267 | fn main() { | ||
268 | } | ||
269 | |||
270 | pub use std::collections::HashMap; | ||
271 | "#, | ||
272 | ); | ||
273 | server.wait_until_workspace_is_loaded(); | ||
274 | |||
275 | server.request::<Formatting>( | ||
276 | DocumentFormattingParams { | ||
277 | text_document: server.doc_id("src/lib.rs"), | ||
278 | options: FormattingOptions { | ||
279 | tab_size: 4, | ||
280 | insert_spaces: false, | ||
281 | properties: HashMap::new(), | ||
282 | insert_final_newline: None, | ||
283 | trim_final_newlines: None, | ||
284 | trim_trailing_whitespace: None, | ||
285 | }, | ||
286 | work_done_progress_params: WorkDoneProgressParams::default(), | ||
287 | }, | ||
288 | json!([ | ||
289 | { | ||
290 | "newText": r#"mod bar; | ||
291 | |||
292 | async fn test() {} | ||
293 | |||
294 | fn main() {} | ||
295 | |||
296 | pub use std::collections::HashMap; | ||
297 | "#, | ||
298 | "range": { | ||
299 | "end": { | ||
300 | "character": 0, | ||
301 | "line": 10 | ||
302 | }, | ||
303 | "start": { | ||
304 | "character": 0, | ||
305 | "line": 0 | ||
306 | } | ||
307 | } | ||
308 | } | ||
309 | ]), | ||
310 | ); | ||
311 | } | ||
312 | |||
313 | #[test] | ||
224 | fn test_missing_module_code_action() { | 314 | fn test_missing_module_code_action() { |
315 | if skip_slow_tests() { | ||
316 | return; | ||
317 | } | ||
318 | |||
225 | let server = project( | 319 | let server = project( |
226 | r#" | 320 | r#" |
227 | //- Cargo.toml | 321 | //- Cargo.toml |
@@ -242,6 +336,8 @@ fn main() {} | |||
242 | text_document: server.doc_id("src/lib.rs"), | 336 | text_document: server.doc_id("src/lib.rs"), |
243 | range: Range::new(Position::new(0, 4), Position::new(0, 7)), | 337 | range: Range::new(Position::new(0, 4), Position::new(0, 7)), |
244 | context: empty_context(), | 338 | context: empty_context(), |
339 | partial_result_params: PartialResultParams::default(), | ||
340 | work_done_progress_params: WorkDoneProgressParams::default(), | ||
245 | }, | 341 | }, |
246 | json!([ | 342 | json!([ |
247 | { | 343 | { |
@@ -273,6 +369,8 @@ fn main() {} | |||
273 | text_document: server.doc_id("src/lib.rs"), | 369 | text_document: server.doc_id("src/lib.rs"), |
274 | range: Range::new(Position::new(2, 4), Position::new(2, 7)), | 370 | range: Range::new(Position::new(2, 4), Position::new(2, 7)), |
275 | context: empty_context(), | 371 | context: empty_context(), |
372 | partial_result_params: PartialResultParams::default(), | ||
373 | work_done_progress_params: WorkDoneProgressParams::default(), | ||
276 | }, | 374 | }, |
277 | json!([]), | 375 | json!([]), |
278 | ); | 376 | ); |
@@ -280,6 +378,10 @@ fn main() {} | |||
280 | 378 | ||
281 | #[test] | 379 | #[test] |
282 | fn test_missing_module_code_action_in_json_project() { | 380 | fn test_missing_module_code_action_in_json_project() { |
381 | if skip_slow_tests() { | ||
382 | return; | ||
383 | } | ||
384 | |||
283 | let tmp_dir = TempDir::new().unwrap(); | 385 | let tmp_dir = TempDir::new().unwrap(); |
284 | 386 | ||
285 | let path = tmp_dir.path(); | 387 | let path = tmp_dir.path(); |
@@ -317,6 +419,8 @@ fn main() {{}} | |||
317 | text_document: server.doc_id("src/lib.rs"), | 419 | text_document: server.doc_id("src/lib.rs"), |
318 | range: Range::new(Position::new(0, 4), Position::new(0, 7)), | 420 | range: Range::new(Position::new(0, 4), Position::new(0, 7)), |
319 | context: empty_context(), | 421 | context: empty_context(), |
422 | partial_result_params: PartialResultParams::default(), | ||
423 | work_done_progress_params: WorkDoneProgressParams::default(), | ||
320 | }, | 424 | }, |
321 | json!([ | 425 | json!([ |
322 | { | 426 | { |
@@ -348,6 +452,8 @@ fn main() {{}} | |||
348 | text_document: server.doc_id("src/lib.rs"), | 452 | text_document: server.doc_id("src/lib.rs"), |
349 | range: Range::new(Position::new(2, 4), Position::new(2, 7)), | 453 | range: Range::new(Position::new(2, 4), Position::new(2, 7)), |
350 | context: empty_context(), | 454 | context: empty_context(), |
455 | partial_result_params: PartialResultParams::default(), | ||
456 | work_done_progress_params: WorkDoneProgressParams::default(), | ||
351 | }, | 457 | }, |
352 | json!([]), | 458 | json!([]), |
353 | ); | 459 | ); |
@@ -355,6 +461,10 @@ fn main() {{}} | |||
355 | 461 | ||
356 | #[test] | 462 | #[test] |
357 | fn diagnostics_dont_block_typing() { | 463 | fn diagnostics_dont_block_typing() { |
464 | if skip_slow_tests() { | ||
465 | return; | ||
466 | } | ||
467 | |||
358 | let librs: String = (0..10).map(|i| format!("mod m{};", i)).collect(); | 468 | let librs: String = (0..10).map(|i| format!("mod m{};", i)).collect(); |
359 | let libs: String = (0..10).map(|i| format!("//- src/m{}.rs\nfn foo() {{}}\n\n", i)).collect(); | 469 | let libs: String = (0..10).map(|i| format!("//- src/m{}.rs\nfn foo() {{}}\n\n", i)).collect(); |
360 | let server = Project::with_fixture(&format!( | 470 | let server = Project::with_fixture(&format!( |
@@ -423,6 +533,10 @@ fn main() {{}} | |||
423 | 533 | ||
424 | #[test] | 534 | #[test] |
425 | fn preserves_dos_line_endings() { | 535 | fn preserves_dos_line_endings() { |
536 | if skip_slow_tests() { | ||
537 | return; | ||
538 | } | ||
539 | |||
426 | let server = Project::with_fixture( | 540 | let server = Project::with_fixture( |
427 | &" | 541 | &" |
428 | //- Cargo.toml | 542 | //- Cargo.toml |
diff --git a/crates/ra_lsp_server/tests/heavy_tests/support.rs b/crates/ra_lsp_server/tests/heavy_tests/support.rs index 86073b57d..d5ea52fa9 100644 --- a/crates/ra_lsp_server/tests/heavy_tests/support.rs +++ b/crates/ra_lsp_server/tests/heavy_tests/support.rs | |||
@@ -7,7 +7,6 @@ use std::{ | |||
7 | }; | 7 | }; |
8 | 8 | ||
9 | use crossbeam_channel::{after, select, Receiver}; | 9 | use crossbeam_channel::{after, select, Receiver}; |
10 | use flexi_logger::Logger; | ||
11 | use lsp_server::{Connection, Message, Notification, Request}; | 10 | use lsp_server::{Connection, Message, Notification, Request}; |
12 | use lsp_types::{ | 11 | use lsp_types::{ |
13 | notification::{DidOpenTextDocument, Exit}, | 12 | notification::{DidOpenTextDocument, Exit}, |
@@ -53,7 +52,7 @@ impl<'a> Project<'a> { | |||
53 | let tmp_dir = self.tmp_dir.unwrap_or_else(|| TempDir::new().unwrap()); | 52 | let tmp_dir = self.tmp_dir.unwrap_or_else(|| TempDir::new().unwrap()); |
54 | static INIT: Once = Once::new(); | 53 | static INIT: Once = Once::new(); |
55 | INIT.call_once(|| { | 54 | INIT.call_once(|| { |
56 | let _ = Logger::with_env_or_str(crate::LOG).start().unwrap(); | 55 | let _ = env_logger::builder().is_test(true).try_init().unwrap(); |
57 | ra_prof::set_filter(if crate::PROFILE.is_empty() { | 56 | ra_prof::set_filter(if crate::PROFILE.is_empty() { |
58 | ra_prof::Filter::disabled() | 57 | ra_prof::Filter::disabled() |
59 | } else { | 58 | } else { |