Skip to content

Commit 964219f

Browse files
author
Jonas Schievink
committed
Allow running a test as a binary
1 parent 84acd56 commit 964219f

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

crates/rust-analyzer/src/cargo_target_spec.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,11 @@ impl CargoTargetSpec {
7272
extra_args.push("--nocapture".to_string());
7373
}
7474
RunnableKind::Bin => {
75-
args.push("run".to_string());
75+
let subcommand = match spec {
76+
Some(CargoTargetSpec { target_kind: TargetKind::Test, .. }) => "test",
77+
_ => "run",
78+
};
79+
args.push(subcommand.to_string());
7680
if let Some(spec) = spec {
7781
spec.push_to(&mut args, kind);
7882
}

crates/rust-analyzer/src/handlers.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1399,7 +1399,10 @@ fn should_skip_target(runnable: &Runnable, cargo_spec: Option<&CargoTargetSpec>)
13991399
RunnableKind::Bin => {
14001400
// Do not suggest binary run on other target than binary
14011401
match &cargo_spec {
1402-
Some(spec) => !matches!(spec.target_kind, TargetKind::Bin | TargetKind::Example),
1402+
Some(spec) => !matches!(
1403+
spec.target_kind,
1404+
TargetKind::Bin | TargetKind::Example | TargetKind::Test
1405+
),
14031406
None => true,
14041407
}
14051408
}

0 commit comments

Comments
 (0)