about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-07-29 21:51:49 +0000
committerGitHub <noreply@github.com>2020-07-29 21:51:49 +0000
commitbd5d236724ff1418b3d3e70fd946374db67479d7 (patch)
tree1680e94c544070a5170b8f133d2897f4cfeb75a2
parent16caadb404de465d8ea1cb6a107740ef004f232b (diff)
parent85d71f4dff6d96678eeb195249fd340dc8cf4912 (diff)
downloadrust-bd5d236724ff1418b3d3e70fd946374db67479d7.tar.gz
rust-bd5d236724ff1418b3d3e70fd946374db67479d7.zip
Merge #5563
5563: Check all targets for package-level tasks r=matklad a=SomeoneToIgnore

When invoking "Select Runnable" with the caret on a runnable with a specific target (test, bench, binary), append the corresponding argument for the `cargo check -p` module runnable.

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
-rw-r--r--crates/rust-analyzer/src/handlers.rs5
-rw-r--r--crates/rust-analyzer/tests/heavy_tests/main.rs8
2 files changed, 7 insertions, 6 deletions
diff --git a/crates/rust-analyzer/src/handlers.rs b/crates/rust-analyzer/src/handlers.rs
index 1350bd4002c..87a1367ac2e 100644
--- a/crates/rust-analyzer/src/handlers.rs
+++ b/crates/rust-analyzer/src/handlers.rs
@@ -469,12 +469,12 @@ pub(crate) fn handle_runnables(
         res.push(runnable);
     }
 
-    // Add `cargo check` and `cargo test` for the whole package
+    // Add `cargo check` and `cargo test` for all targets of the whole package
     match cargo_spec {
         Some(spec) => {
             for &cmd in ["check", "test"].iter() {
                 res.push(lsp_ext::Runnable {
-                    label: format!("cargo {} -p {}", cmd, spec.package),
+                    label: format!("cargo {} -p {} --all-targets", cmd, spec.package),
                     location: None,
                     kind: lsp_ext::RunnableKind::Cargo,
                     args: lsp_ext::CargoRunnable {
@@ -483,6 +483,7 @@ pub(crate) fn handle_runnables(
                             cmd.to_string(),
                             "--package".to_string(),
                             spec.package.clone(),
+                            "--all-targets".to_string(),
                         ],
                         executable_args: Vec::new(),
                         expect_test: None,
diff --git a/crates/rust-analyzer/tests/heavy_tests/main.rs b/crates/rust-analyzer/tests/heavy_tests/main.rs
index 28e89664873..7370505f8bf 100644
--- a/crates/rust-analyzer/tests/heavy_tests/main.rs
+++ b/crates/rust-analyzer/tests/heavy_tests/main.rs
@@ -115,21 +115,21 @@ fn main() {}
           },
           {
             "args": {
-              "cargoArgs": ["check", "--package", "foo"],
+              "cargoArgs": ["check", "--package", "foo", "--all-targets"],
               "executableArgs": [],
               "workspaceRoot": server.path().join("foo")
             },
             "kind": "cargo",
-            "label": "cargo check -p foo"
+            "label": "cargo check -p foo --all-targets"
           },
           {
             "args": {
-              "cargoArgs": ["test", "--package", "foo"],
+              "cargoArgs": ["test", "--package", "foo", "--all-targets"],
               "executableArgs": [],
               "workspaceRoot": server.path().join("foo")
             },
             "kind": "cargo",
-            "label": "cargo test -p foo"
+            "label": "cargo test -p foo --all-targets"
           }
         ]),
     );