From 6322f370153df85fccc4c8e2fe4c9bdf451d921b Mon Sep 17 00:00:00 2001 From: David Peter Date: Wed, 12 Nov 2025 11:02:29 +0100 Subject: [PATCH] [ty] Better assertion message for benchmark diagnostics check (#21398) I don't know why, but it always takes me an eternity to find the failing project name a few lines below in the output. So I'm suggesting we just add the project name to the assertion message. --- crates/ruff_benchmark/benches/ty_walltime.rs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/crates/ruff_benchmark/benches/ty_walltime.rs b/crates/ruff_benchmark/benches/ty_walltime.rs index 2b02230fd6..cb5fd32014 100644 --- a/crates/ruff_benchmark/benches/ty_walltime.rs +++ b/crates/ruff_benchmark/benches/ty_walltime.rs @@ -71,16 +71,13 @@ impl Display for Benchmark<'_> { } } -fn check_project(db: &ProjectDatabase, max_diagnostics: usize) { +fn check_project(db: &ProjectDatabase, project_name: &str, max_diagnostics: usize) { let result = db.check(); let diagnostics = result.len(); assert!( diagnostics > 1 && diagnostics <= max_diagnostics, - "Expected between {} and {} diagnostics but got {}", - 1, - max_diagnostics, - diagnostics + "Expected between 1 and {max_diagnostics} diagnostics on project '{project_name}' but got {diagnostics}", ); } @@ -234,7 +231,7 @@ fn run_single_threaded(bencher: Bencher, benchmark: &Benchmark) { bencher .with_inputs(|| benchmark.setup_iteration()) .bench_local_refs(|db| { - check_project(db, benchmark.max_diagnostics); + check_project(db, benchmark.project.name, benchmark.max_diagnostics); }); } @@ -261,7 +258,7 @@ fn multithreaded(bencher: Bencher, benchmark: &Benchmark) { .with_inputs(|| benchmark.setup_iteration()) .bench_local_values(|db| { thread_pool.install(|| { - check_project(&db, benchmark.max_diagnostics); + check_project(&db, benchmark.project.name, benchmark.max_diagnostics); db }) }); @@ -285,7 +282,7 @@ fn main() { // branch when looking up the ingredient index. { let db = TANJUN.setup_iteration(); - check_project(&db, TANJUN.max_diagnostics); + check_project(&db, TANJUN.project.name, TANJUN.max_diagnostics); } divan::main();