From 426c0f26fe90e7d4fcf5950e217a64843e651fe9 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Sat, 15 Feb 2020 01:06:14 +0200 Subject: If possible, use --exact flag when running tests --- crates/ra_lsp_server/src/cargo_target_spec.rs | 16 +++++++++++----- crates/ra_lsp_server/src/main_loop/handlers.rs | 4 ++-- 2 files changed, 13 insertions(+), 7 deletions(-) (limited to 'crates/ra_lsp_server') diff --git a/crates/ra_lsp_server/src/cargo_target_spec.rs b/crates/ra_lsp_server/src/cargo_target_spec.rs index 594caffe2..5fd1e7b6b 100644 --- a/crates/ra_lsp_server/src/cargo_target_spec.rs +++ b/crates/ra_lsp_server/src/cargo_target_spec.rs @@ -1,6 +1,6 @@ //! FIXME: write short doc here -use ra_ide::{FileId, RunnableKind}; +use ra_ide::{FileId, RunnableKind, TestId}; use ra_project_model::{self, ProjectWorkspace, TargetKind}; use crate::{world::WorldSnapshot, Result}; @@ -13,13 +13,16 @@ pub(crate) fn runnable_args( let spec = CargoTargetSpec::for_file(world, file_id)?; let mut res = Vec::new(); match kind { - RunnableKind::Test { name } => { + RunnableKind::Test { test_id } => { res.push("test".to_string()); if let Some(spec) = spec { spec.push_to(&mut res); } res.push("--".to_string()); - res.push(name.to_string()); + res.push(test_id.to_string()); + if let TestId::Path(_) = test_id { + res.push("--exact".to_string()); + } res.push("--nocapture".to_string()); } RunnableKind::TestMod { path } => { @@ -31,13 +34,16 @@ pub(crate) fn runnable_args( res.push(path.to_string()); res.push("--nocapture".to_string()); } - RunnableKind::Bench { name } => { + RunnableKind::Bench { test_id } => { res.push("bench".to_string()); if let Some(spec) = spec { spec.push_to(&mut res); } res.push("--".to_string()); - res.push(name.to_string()); + res.push(test_id.to_string()); + if let TestId::Path(_) = test_id { + res.push("--exact".to_string()); + } res.push("--nocapture".to_string()); } RunnableKind::Bin => { diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs index 2e598fdcd..5879a1f7a 100644 --- a/crates/ra_lsp_server/src/main_loop/handlers.rs +++ b/crates/ra_lsp_server/src/main_loop/handlers.rs @@ -918,9 +918,9 @@ fn to_lsp_runnable( let args = runnable_args(world, file_id, &runnable.kind)?; let line_index = world.analysis().file_line_index(file_id)?; let label = match &runnable.kind { - RunnableKind::Test { name } => format!("test {}", name), + RunnableKind::Test { test_id } => format!("test {}", test_id), RunnableKind::TestMod { path } => format!("test-mod {}", path), - RunnableKind::Bench { name } => format!("bench {}", name), + RunnableKind::Bench { test_id } => format!("bench {}", test_id), RunnableKind::Bin => "run binary".to_string(), }; Ok(req::Runnable { -- cgit v1.2.3 From f0338cea5b3a214fe5e72eec68670b161530e1a6 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Sun, 16 Feb 2020 18:55:52 +0200 Subject: Fix a slow test --- crates/ra_lsp_server/tests/heavy_tests/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'crates/ra_lsp_server') diff --git a/crates/ra_lsp_server/tests/heavy_tests/main.rs b/crates/ra_lsp_server/tests/heavy_tests/main.rs index dff63a12d..9ca31cbcc 100644 --- a/crates/ra_lsp_server/tests/heavy_tests/main.rs +++ b/crates/ra_lsp_server/tests/heavy_tests/main.rs @@ -147,7 +147,7 @@ fn main() {} }, json!([ { - "args": [ "test", "--package", "foo", "--test", "spam", "--", "test_eggs", "--nocapture" ], + "args": [ "test", "--package", "foo", "--test", "spam", "--", "test_eggs", "--exact", "--nocapture" ], "bin": "cargo", "env": { "RUST_BACKTRACE": "short" }, "label": "test test_eggs", -- cgit v1.2.3