Skip to content

Commit bd5d236

Browse files
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 <[email protected]>
2 parents 16caadb + 85d71f4 commit bd5d236

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

crates/rust-analyzer/src/handlers.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -469,12 +469,12 @@ pub(crate) fn handle_runnables(
469469
res.push(runnable);
470470
}
471471

472-
// Add `cargo check` and `cargo test` for the whole package
472+
// Add `cargo check` and `cargo test` for all targets of the whole package
473473
match cargo_spec {
474474
Some(spec) => {
475475
for &cmd in ["check", "test"].iter() {
476476
res.push(lsp_ext::Runnable {
477-
label: format!("cargo {} -p {}", cmd, spec.package),
477+
label: format!("cargo {} -p {} --all-targets", cmd, spec.package),
478478
location: None,
479479
kind: lsp_ext::RunnableKind::Cargo,
480480
args: lsp_ext::CargoRunnable {
@@ -483,6 +483,7 @@ pub(crate) fn handle_runnables(
483483
cmd.to_string(),
484484
"--package".to_string(),
485485
spec.package.clone(),
486+
"--all-targets".to_string(),
486487
],
487488
executable_args: Vec::new(),
488489
expect_test: None,

crates/rust-analyzer/tests/heavy_tests/main.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,21 +115,21 @@ fn main() {}
115115
},
116116
{
117117
"args": {
118-
"cargoArgs": ["check", "--package", "foo"],
118+
"cargoArgs": ["check", "--package", "foo", "--all-targets"],
119119
"executableArgs": [],
120120
"workspaceRoot": server.path().join("foo")
121121
},
122122
"kind": "cargo",
123-
"label": "cargo check -p foo"
123+
"label": "cargo check -p foo --all-targets"
124124
},
125125
{
126126
"args": {
127-
"cargoArgs": ["test", "--package", "foo"],
127+
"cargoArgs": ["test", "--package", "foo", "--all-targets"],
128128
"executableArgs": [],
129129
"workspaceRoot": server.path().join("foo")
130130
},
131131
"kind": "cargo",
132-
"label": "cargo test -p foo"
132+
"label": "cargo test -p foo --all-targets"
133133
}
134134
]),
135135
);

0 commit comments

Comments
 (0)