Skip to content

Commit 7952680

Browse files
committed
No printing executable names when running tests with json message format
1 parent 83a7983 commit 7952680

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

src/cargo/ops/cargo_test.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ pub fn run_tests(
2222
let compilation = compile_tests(ws, options)?;
2323

2424
if options.no_run {
25-
display_no_run_information(ws, test_args, &compilation, "unittests")?;
25+
if !options.compile_opts.build_config.emit_json() {
26+
display_no_run_information(ws, test_args, &compilation, "unittests")?;
27+
}
28+
2629
return Ok(None);
2730
}
2831
let (test, mut errors) = run_unit_tests(ws.config(), options, test_args, &compilation)?;

tests/testsuite/test.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1352,6 +1352,22 @@ fn test_no_run() {
13521352
.run();
13531353
}
13541354

1355+
#[cargo_test]
1356+
fn test_no_run_emit_json() {
1357+
let p = project()
1358+
.file("src/lib.rs", "#[test] fn foo() { panic!() }")
1359+
.build();
1360+
1361+
p.cargo("test --no-run --message-format json")
1362+
.with_stderr(
1363+
"\
1364+
[COMPILING] foo v0.0.1 ([CWD])
1365+
[FINISHED] test [unoptimized + debuginfo] target(s) in [..]
1366+
",
1367+
)
1368+
.run();
1369+
}
1370+
13551371
#[cargo_test]
13561372
fn test_run_specific_bin_target() {
13571373
let prj = project()

0 commit comments

Comments
 (0)