From 8ec5f2fcdcdd2e2a9297093189ad8c05e1dd7a8f Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 7 Dec 2019 12:46:36 +0100 Subject: Skip slow tests by default --- .github/workflows/ci.yaml | 8 ++++-- crates/ra_lsp_server/tests/heavy_tests/main.rs | 38 ++++++++++++++++++++++++++ crates/test_utils/src/lib.rs | 11 ++++++++ 3 files changed, 54 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 5bc41533c..cb397ae14 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -14,6 +14,7 @@ jobs: env: RUSTFLAGS: -D warnings CARGO_INCREMENTAL: 0 + RUN_SLOW_TESTS: 1 steps: - name: Checkout repository @@ -46,9 +47,10 @@ jobs: - name: Prepare build directory for cache run: | - find ./target/debug -maxdepth 1 -type f -delete && \ - rm -fr ./target/debug/{deps,.fingerprint}/{*ra_*,*heavy_test*,*gen_lsp*,*thread_worker*} && \ - rm -f ./target/.rustc_info.json + find ./target/debug -maxdepth 1 -type f -delete \ + && rm -fr ./target/debug/{deps,.fingerprint}/{*ra_*,*heavy_test*,*gen_lsp*,*thread_worker*} \ + && rm -f ./target/.rustc_info.json \ + && rm ./target/.slow_tests_cookie type-script: name: TypeScript 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::{ }; use serde_json::json; use tempfile::TempDir; +use test_utils::skip_slow_tests; use crate::support::{project, Project}; @@ -20,6 +21,10 @@ const PROFILE: &'static str = ""; #[test] fn completes_items_from_standard_library() { + if skip_slow_tests() { + return; + } + let project_start = Instant::now(); let server = Project::with_fixture( r#" @@ -50,6 +55,10 @@ use std::collections::Spam; #[test] fn test_runnables_no_project() { + if skip_slow_tests() { + return; + } + let server = project( r" //- lib.rs @@ -99,6 +108,10 @@ fn foo() { #[test] fn test_runnables_project() { + if skip_slow_tests() { + return; + } + let code = r#" //- foo/Cargo.toml [package] @@ -170,6 +183,10 @@ fn main() {} #[test] fn test_format_document() { + if skip_slow_tests() { + return; + } + let server = project( r#" //- Cargo.toml @@ -222,6 +239,10 @@ pub use std::collections::HashMap; #[test] fn test_format_document_2018() { + if skip_slow_tests() { + return; + } + let server = project( r#" //- Cargo.toml @@ -277,8 +298,13 @@ pub use std::collections::HashMap; ]), ); } + #[test] fn test_missing_module_code_action() { + if skip_slow_tests() { + return; + } + let server = project( r#" //- Cargo.toml @@ -337,6 +363,10 @@ fn main() {} #[test] fn test_missing_module_code_action_in_json_project() { + if skip_slow_tests() { + return; + } + let tmp_dir = TempDir::new().unwrap(); let path = tmp_dir.path(); @@ -412,6 +442,10 @@ fn main() {{}} #[test] fn diagnostics_dont_block_typing() { + if skip_slow_tests() { + return; + } + 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::with_fixture(&format!( @@ -480,6 +514,10 @@ fn main() {{}} #[test] fn preserves_dos_line_endings() { + if skip_slow_tests() { + return; + } + let server = Project::with_fixture( &" //- 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 { .replace("\r\n", "\n") } +pub fn skip_slow_tests() -> bool { + let should_skip = std::env::var("CI").is_err() && std::env::var("RUN_SLOW_TESTS").is_err(); + if should_skip { + eprintln!("ignoring slow test") + } else { + let path = project_dir().join("./target/.slow_tests_cookie"); + fs::write(&path, ".").unwrap(); + } + should_skip +} + const REWRITE: bool = false; fn assert_equal_text(expected: &str, actual: &str, path: &Path) { -- cgit v1.2.3