diff options
author | Aleksey Kladov <[email protected]> | 2019-12-07 11:46:36 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-12-07 12:19:42 +0000 |
commit | 8ec5f2fcdcdd2e2a9297093189ad8c05e1dd7a8f (patch) | |
tree | dcaffc3800d3b42514584b2652863c9c99e422bc /crates | |
parent | 431836f4a01dda39d10f6275915f9c8e99a28028 (diff) |
Skip slow tests by default
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_lsp_server/tests/heavy_tests/main.rs | 38 | ||||
-rw-r--r-- | crates/test_utils/src/lib.rs | 11 |
2 files changed, 49 insertions, 0 deletions
diff --git a/crates/ra_lsp_server/tests/heavy_tests/main.rs b/crates/ra_lsp_server/tests/heavy_tests/main.rs index fec50bd25..cfbf16ea5 100644 --- a/crates/ra_lsp_server/tests/heavy_tests/main.rs +++ b/crates/ra_lsp_server/tests/heavy_tests/main.rs | |||
@@ -12,6 +12,7 @@ use ra_lsp_server::req::{ | |||
12 | }; | 12 | }; |
13 | use serde_json::json; | 13 | use serde_json::json; |
14 | use tempfile::TempDir; | 14 | use tempfile::TempDir; |
15 | use test_utils::skip_slow_tests; | ||
15 | 16 | ||
16 | use crate::support::{project, Project}; | 17 | use crate::support::{project, Project}; |
17 | 18 | ||
@@ -20,6 +21,10 @@ const PROFILE: &'static str = ""; | |||
20 | 21 | ||
21 | #[test] | 22 | #[test] |
22 | fn completes_items_from_standard_library() { | 23 | fn completes_items_from_standard_library() { |
24 | if skip_slow_tests() { | ||
25 | return; | ||
26 | } | ||
27 | |||
23 | let project_start = Instant::now(); | 28 | let project_start = Instant::now(); |
24 | let server = Project::with_fixture( | 29 | let server = Project::with_fixture( |
25 | r#" | 30 | r#" |
@@ -50,6 +55,10 @@ use std::collections::Spam; | |||
50 | 55 | ||
51 | #[test] | 56 | #[test] |
52 | fn test_runnables_no_project() { | 57 | fn test_runnables_no_project() { |
58 | if skip_slow_tests() { | ||
59 | return; | ||
60 | } | ||
61 | |||
53 | let server = project( | 62 | let server = project( |
54 | r" | 63 | r" |
55 | //- lib.rs | 64 | //- lib.rs |
@@ -99,6 +108,10 @@ fn foo() { | |||
99 | 108 | ||
100 | #[test] | 109 | #[test] |
101 | fn test_runnables_project() { | 110 | fn test_runnables_project() { |
111 | if skip_slow_tests() { | ||
112 | return; | ||
113 | } | ||
114 | |||
102 | let code = r#" | 115 | let code = r#" |
103 | //- foo/Cargo.toml | 116 | //- foo/Cargo.toml |
104 | [package] | 117 | [package] |
@@ -170,6 +183,10 @@ fn main() {} | |||
170 | 183 | ||
171 | #[test] | 184 | #[test] |
172 | fn test_format_document() { | 185 | fn test_format_document() { |
186 | if skip_slow_tests() { | ||
187 | return; | ||
188 | } | ||
189 | |||
173 | let server = project( | 190 | let server = project( |
174 | r#" | 191 | r#" |
175 | //- Cargo.toml | 192 | //- Cargo.toml |
@@ -222,6 +239,10 @@ pub use std::collections::HashMap; | |||
222 | 239 | ||
223 | #[test] | 240 | #[test] |
224 | fn test_format_document_2018() { | 241 | fn test_format_document_2018() { |
242 | if skip_slow_tests() { | ||
243 | return; | ||
244 | } | ||
245 | |||
225 | let server = project( | 246 | let server = project( |
226 | r#" | 247 | r#" |
227 | //- Cargo.toml | 248 | //- Cargo.toml |
@@ -277,8 +298,13 @@ pub use std::collections::HashMap; | |||
277 | ]), | 298 | ]), |
278 | ); | 299 | ); |
279 | } | 300 | } |
301 | |||
280 | #[test] | 302 | #[test] |
281 | fn test_missing_module_code_action() { | 303 | fn test_missing_module_code_action() { |
304 | if skip_slow_tests() { | ||
305 | return; | ||
306 | } | ||
307 | |||
282 | let server = project( | 308 | let server = project( |
283 | r#" | 309 | r#" |
284 | //- Cargo.toml | 310 | //- Cargo.toml |
@@ -337,6 +363,10 @@ fn main() {} | |||
337 | 363 | ||
338 | #[test] | 364 | #[test] |
339 | fn test_missing_module_code_action_in_json_project() { | 365 | fn test_missing_module_code_action_in_json_project() { |
366 | if skip_slow_tests() { | ||
367 | return; | ||
368 | } | ||
369 | |||
340 | let tmp_dir = TempDir::new().unwrap(); | 370 | let tmp_dir = TempDir::new().unwrap(); |
341 | 371 | ||
342 | let path = tmp_dir.path(); | 372 | let path = tmp_dir.path(); |
@@ -412,6 +442,10 @@ fn main() {{}} | |||
412 | 442 | ||
413 | #[test] | 443 | #[test] |
414 | fn diagnostics_dont_block_typing() { | 444 | fn diagnostics_dont_block_typing() { |
445 | if skip_slow_tests() { | ||
446 | return; | ||
447 | } | ||
448 | |||
415 | let librs: String = (0..10).map(|i| format!("mod m{};", i)).collect(); | 449 | let librs: String = (0..10).map(|i| format!("mod m{};", i)).collect(); |
416 | let libs: String = (0..10).map(|i| format!("//- src/m{}.rs\nfn foo() {{}}\n\n", i)).collect(); | 450 | let libs: String = (0..10).map(|i| format!("//- src/m{}.rs\nfn foo() {{}}\n\n", i)).collect(); |
417 | let server = Project::with_fixture(&format!( | 451 | let server = Project::with_fixture(&format!( |
@@ -480,6 +514,10 @@ fn main() {{}} | |||
480 | 514 | ||
481 | #[test] | 515 | #[test] |
482 | fn preserves_dos_line_endings() { | 516 | fn preserves_dos_line_endings() { |
517 | if skip_slow_tests() { | ||
518 | return; | ||
519 | } | ||
520 | |||
483 | let server = Project::with_fixture( | 521 | let server = Project::with_fixture( |
484 | &" | 522 | &" |
485 | //- Cargo.toml | 523 | //- Cargo.toml |
diff --git a/crates/test_utils/src/lib.rs b/crates/test_utils/src/lib.rs index 1244ea8cf..657ddf2a6 100644 --- a/crates/test_utils/src/lib.rs +++ b/crates/test_utils/src/lib.rs | |||
@@ -356,6 +356,17 @@ pub fn read_text(path: &Path) -> String { | |||
356 | .replace("\r\n", "\n") | 356 | .replace("\r\n", "\n") |
357 | } | 357 | } |
358 | 358 | ||
359 | pub fn skip_slow_tests() -> bool { | ||
360 | let should_skip = std::env::var("CI").is_err() && std::env::var("RUN_SLOW_TESTS").is_err(); | ||
361 | if should_skip { | ||
362 | eprintln!("ignoring slow test") | ||
363 | } else { | ||
364 | let path = project_dir().join("./target/.slow_tests_cookie"); | ||
365 | fs::write(&path, ".").unwrap(); | ||
366 | } | ||
367 | should_skip | ||
368 | } | ||
369 | |||
359 | const REWRITE: bool = false; | 370 | const REWRITE: bool = false; |
360 | 371 | ||
361 | fn assert_equal_text(expected: &str, actual: &str, path: &Path) { | 372 | fn assert_equal_text(expected: &str, actual: &str, path: &Path) { |