From 8923641fdbd9764c1c3fca5bcbe31ee41bab5664 Mon Sep 17 00:00:00 2001 From: Adrien Cacciaguerra Date: Tue, 14 Oct 2025 16:23:21 +0200 Subject: [PATCH] feat(cargo-codspeed): add explicit mode with command when no benchmarks are found in run --- crates/cargo-codspeed/src/run.rs | 2 +- crates/cargo-codspeed/tests/simple-bencher.rs | 2 +- crates/cargo-codspeed/tests/simple-criterion.rs | 2 +- crates/cargo-codspeed/tests/simple-divan.rs | 2 +- crates/cargo-codspeed/tests/workspace.rs | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/crates/cargo-codspeed/src/run.rs b/crates/cargo-codspeed/src/run.rs index aaa4914b..1dc10393 100644 --- a/crates/cargo-codspeed/src/run.rs +++ b/crates/cargo-codspeed/src/run.rs @@ -108,7 +108,7 @@ pub fn run_benches( let benches = package_filters.benches_to_run(metadata, bench_target_filters, codspeed_target_dir)?; if benches.is_empty() { - bail!("No benchmarks found. Run `cargo codspeed build` first."); + bail!("No benchmarks found for the {measurement_mode} mode. Run `cargo codspeed build -m {measurement_mode}` first."); } eprintln!("Collected {} benchmark suite(s) to run", benches.len()); diff --git a/crates/cargo-codspeed/tests/simple-bencher.rs b/crates/cargo-codspeed/tests/simple-bencher.rs index e193c61e..d1643a05 100644 --- a/crates/cargo-codspeed/tests/simple-bencher.rs +++ b/crates/cargo-codspeed/tests/simple-bencher.rs @@ -13,7 +13,7 @@ fn test_simple_run_without_build() { .arg("run") .assert() .failure() - .stderr(contains("Error: No benchmarks found.")); + .stderr(contains("Error: No benchmarks found for the instrumentation mode. Run `cargo codspeed build -m instrumentation` first.")); teardown(dir); } diff --git a/crates/cargo-codspeed/tests/simple-criterion.rs b/crates/cargo-codspeed/tests/simple-criterion.rs index 35141b5f..3dc3e2e6 100644 --- a/crates/cargo-codspeed/tests/simple-criterion.rs +++ b/crates/cargo-codspeed/tests/simple-criterion.rs @@ -15,7 +15,7 @@ fn test_criterion_run_without_build() { .arg("run") .assert() .failure() - .stderr(contains("Error: No benchmarks found.")); + .stderr(contains("Error: No benchmarks found for the instrumentation mode. Run `cargo codspeed build -m instrumentation` first.")); teardown(dir); } diff --git a/crates/cargo-codspeed/tests/simple-divan.rs b/crates/cargo-codspeed/tests/simple-divan.rs index 057a5686..46a72fcd 100644 --- a/crates/cargo-codspeed/tests/simple-divan.rs +++ b/crates/cargo-codspeed/tests/simple-divan.rs @@ -15,7 +15,7 @@ fn test_divan_run_without_build() { .arg("run") .assert() .failure() - .stderr(contains("Error: No benchmarks found.")); + .stderr(contains("Error: No benchmarks found for the instrumentation mode. Run `cargo codspeed build -m instrumentation` first.")); teardown(dir); } diff --git a/crates/cargo-codspeed/tests/workspace.rs b/crates/cargo-codspeed/tests/workspace.rs index 337016e3..4bbae74e 100644 --- a/crates/cargo-codspeed/tests/workspace.rs +++ b/crates/cargo-codspeed/tests/workspace.rs @@ -12,7 +12,7 @@ fn test_workspace_run_without_build() { .arg("run") .assert() .failure() - .stderr(contains("Error: No benchmarks found.")); + .stderr(contains("Error: No benchmarks found for the instrumentation mode. Run `cargo codspeed build -m instrumentation` first.")); teardown(dir); } @@ -62,7 +62,7 @@ fn test_workspace_build_subpackage_and_run_other() { .args(["--package", "package-b"]) .assert() .failure() - .stderr(contains("Error: No benchmarks found.")); + .stderr(contains("Error: No benchmarks found for the instrumentation mode. Run `cargo codspeed build -m instrumentation` first.")); teardown(dir); }