Skip to content

Commit 3388af9

Browse files
d-e-s-odjc
authored andcommitted
Honor --unit-test-kind work with --unit-bench
Commit 512f20c ("Add unit-test-kind option to allow choosing bin or lib") added support for specifying the unit test "kind" when running unit tests. The reasoning brought up there (and solution introduced) applies to unit benches as well. So make --unit-bench honor the value of this option as well.
1 parent 0672d88 commit 3388af9

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

src/bin/cargo-flamegraph.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ struct Opt {
4949
#[clap(long, group = "exec-args")]
5050
unit_test: Option<Option<String>>,
5151

52-
/// Kind of target (lib or bin) when running with <unit-test> which is may be
53-
/// required when we have two targets with the same name.
52+
/// Kind of target (lib or bin) when running with <unit-test> or <unit-bench> which is
53+
/// may be required when we have two targets with the same name.
5454
#[clap(long)]
5555
unit_test_kind: Option<UnitTestTargetKind>,
5656

@@ -469,8 +469,14 @@ fn main() -> anyhow::Result<()> {
469469
opt.package = Some(target.package);
470470
target.kind
471471
} else if let Some(unit_bench) = opt.unit_bench {
472+
let kinds = match opt.unit_test_kind {
473+
Some(UnitTestTargetKind::Bin) => &[TargetKind::Bin][..],
474+
Some(UnitTestTargetKind::Lib) => &[TargetKind::Lib, TargetKind::RLib],
475+
None => &[TargetKind::Bin, TargetKind::Lib, TargetKind::RLib],
476+
};
477+
472478
let target = find_unique_target(
473-
&[TargetKind::Bin, TargetKind::Lib, TargetKind::RLib],
479+
kinds,
474480
opt.package.as_deref(),
475481
opt.manifest_path.as_deref(),
476482
unit_bench.as_deref(),

0 commit comments

Comments
 (0)