Skip to content

Commit e04d777

Browse files
committed
No printing executable names when running benches with json message format
1 parent 7952680 commit e04d777

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

src/cargo/ops/cargo_test.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,10 @@ pub fn run_benches(
5353
let compilation = compile_tests(ws, options)?;
5454

5555
if options.no_run {
56-
display_no_run_information(ws, args, &compilation, "benches")?;
56+
if !options.compile_opts.build_config.emit_json() {
57+
display_no_run_information(ws, args, &compilation, "benches")?;
58+
}
59+
5760
return Ok(None);
5861
}
5962

tests/testsuite/bench.rs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1216,6 +1216,39 @@ fn test_bench_no_run() {
12161216
.run();
12171217
}
12181218

1219+
#[cargo_test]
1220+
fn test_bench_no_run_emit_json() {
1221+
if !is_nightly() {
1222+
return;
1223+
}
1224+
1225+
let p = project()
1226+
.file("src/lib.rs", "")
1227+
.file(
1228+
"benches/bbaz.rs",
1229+
r#"
1230+
#![feature(test)]
1231+
1232+
extern crate test;
1233+
1234+
use test::Bencher;
1235+
1236+
#[bench]
1237+
fn bench_baz(_: &mut Bencher) {}
1238+
"#,
1239+
)
1240+
.build();
1241+
1242+
p.cargo("bench --no-run --message-format json")
1243+
.with_stderr(
1244+
"\
1245+
[COMPILING] foo v0.0.1 ([..])
1246+
[FINISHED] bench [optimized] target(s) in [..]
1247+
",
1248+
)
1249+
.run();
1250+
}
1251+
12191252
#[cargo_test]
12201253
fn test_bench_no_fail_fast() {
12211254
if !is_nightly() {

0 commit comments

Comments
 (0)