diff --git a/library/test/src/console.rs b/library/test/src/console.rs index c7e8507113e0c..56eef8314fbde 100644 --- a/library/test/src/console.rs +++ b/library/test/src/console.rs @@ -118,7 +118,7 @@ impl ConsoleTestState { TestResult::TrIgnored => { #[cfg(not(bootstrap))] if let Some(msg) = ignore_message { - format!("ignored, {msg}") + format!("ignored: {msg}") } else { "ignored".to_owned() } diff --git a/library/test/src/formatters/json.rs b/library/test/src/formatters/json.rs index c089bfc4791b5..737921c1e10dc 100644 --- a/library/test/src/formatters/json.rs +++ b/library/test/src/formatters/json.rs @@ -121,6 +121,19 @@ impl OutputFormatter for JsonFormatter { ), TestResult::TrIgnored => { + #[cfg(not(bootstrap))] + return self.write_event( + "test", + desc.name.as_slice(), + "ignored", + exec_time, + stdout, + desc.ignore_message + .map(|msg| format!(r#""message": "{}""#, EscapedString(msg))) + .as_deref(), + ); + + #[cfg(bootstrap)] self.write_event("test", desc.name.as_slice(), "ignored", exec_time, stdout, None) } diff --git a/library/test/src/formatters/pretty.rs b/library/test/src/formatters/pretty.rs index f55d390aa5621..9b407df2190f3 100644 --- a/library/test/src/formatters/pretty.rs +++ b/library/test/src/formatters/pretty.rs @@ -45,8 +45,12 @@ impl PrettyFormatter { self.write_short_result("FAILED", term::color::RED) } - pub fn write_ignored(&mut self) -> io::Result<()> { - self.write_short_result("ignored", term::color::YELLOW) + pub fn write_ignored(&mut self, message: Option<&'static str>) -> io::Result<()> { + if let Some(message) = message { + self.write_short_result(&format!("ignored, {}", message), term::color::YELLOW) + } else { + self.write_short_result("ignored", term::color::YELLOW) + } } pub fn write_time_failed(&mut self) -> io::Result<()> { @@ -214,7 +218,12 @@ impl OutputFormatter for PrettyFormatter { match *result { TestResult::TrOk => self.write_ok()?, TestResult::TrFailed | TestResult::TrFailedMsg(_) => self.write_failed()?, - TestResult::TrIgnored => self.write_ignored()?, + TestResult::TrIgnored => { + #[cfg(not(bootstrap))] + self.write_ignored(desc.ignore_message)?; + #[cfg(bootstrap)] + self.write_ignored(None)?; + } TestResult::TrBench(ref bs) => { self.write_bench()?; self.write_plain(&format!(": {}", fmt_bench_samples(bs)))?; diff --git a/src/test/run-make-fulldeps/libtest-json/Makefile b/src/test/run-make-fulldeps/libtest-json/Makefile index f61a1aa84100f..67b5fc2ed32dc 100644 --- a/src/test/run-make-fulldeps/libtest-json/Makefile +++ b/src/test/run-make-fulldeps/libtest-json/Makefile @@ -5,7 +5,7 @@ OUTPUT_FILE_DEFAULT := $(TMPDIR)/libtest-json-output-default.json OUTPUT_FILE_STDOUT_SUCCESS := $(TMPDIR)/libtest-json-output-stdout-success.json -all: +all: f.rs validate_json.py output-default.json output-stdout-success.json $(RUSTC) --test f.rs RUST_BACKTRACE=0 $(call RUN,f) -Z unstable-options --test-threads=1 --format=json > $(OUTPUT_FILE_DEFAULT) || true RUST_BACKTRACE=0 $(call RUN,f) -Z unstable-options --test-threads=1 --format=json --show-output > $(OUTPUT_FILE_STDOUT_SUCCESS) || true diff --git a/src/test/run-make-fulldeps/libtest-json/f.rs b/src/test/run-make-fulldeps/libtest-json/f.rs index 95ff36bd764ec..edfe25086ae9a 100644 --- a/src/test/run-make-fulldeps/libtest-json/f.rs +++ b/src/test/run-make-fulldeps/libtest-json/f.rs @@ -16,7 +16,7 @@ fn c() { } #[test] -#[ignore] +#[ignore = "msg"] fn d() { assert!(false); } diff --git a/src/test/run-make-fulldeps/libtest-json/output-default.json b/src/test/run-make-fulldeps/libtest-json/output-default.json index e2c778aa86509..63342abc6ef71 100644 --- a/src/test/run-make-fulldeps/libtest-json/output-default.json +++ b/src/test/run-make-fulldeps/libtest-json/output-default.json @@ -6,5 +6,5 @@ { "type": "test", "event": "started", "name": "c" } { "type": "test", "name": "c", "event": "ok" } { "type": "test", "event": "started", "name": "d" } -{ "type": "test", "name": "d", "event": "ignored" } +{ "type": "test", "name": "d", "event": "ignored", "message": "msg" } { "type": "suite", "event": "failed", "passed": 2, "failed": 1, "ignored": 1, "measured": 0, "filtered_out": 0, "exec_time": $TIME } diff --git a/src/test/run-make-fulldeps/libtest-json/output-stdout-success.json b/src/test/run-make-fulldeps/libtest-json/output-stdout-success.json index 68eb00c297ea7..8f19114460e89 100644 --- a/src/test/run-make-fulldeps/libtest-json/output-stdout-success.json +++ b/src/test/run-make-fulldeps/libtest-json/output-stdout-success.json @@ -6,5 +6,5 @@ { "type": "test", "event": "started", "name": "c" } { "type": "test", "name": "c", "event": "ok", "stdout": "thread 'main' panicked at 'assertion failed: false', f.rs:15:5\n" } { "type": "test", "event": "started", "name": "d" } -{ "type": "test", "name": "d", "event": "ignored" } +{ "type": "test", "name": "d", "event": "ignored", "message": "msg" } { "type": "suite", "event": "failed", "passed": 2, "failed": 1, "ignored": 1, "measured": 0, "filtered_out": 0, "exec_time": $TIME } diff --git a/src/test/ui/test-attrs/test-type.rs b/src/test/ui/test-attrs/test-type.rs index 3f0fa81373f10..f99e476eabae3 100644 --- a/src/test/ui/test-attrs/test-type.rs +++ b/src/test/ui/test-attrs/test-type.rs @@ -5,7 +5,6 @@ // ignore-emscripten no threads support // run-pass - #[test] fn test_ok() { let _a = true; @@ -18,9 +17,9 @@ fn test_panic() { } #[test] -#[ignore] +#[ignore = "msg"] fn test_no_run() { - loop{ + loop { println!("Hello, world"); } } diff --git a/src/test/ui/test-attrs/test-type.run.stdout b/src/test/ui/test-attrs/test-type.run.stdout index be2fd8ae68c36..143c13a36b7e7 100644 --- a/src/test/ui/test-attrs/test-type.run.stdout +++ b/src/test/ui/test-attrs/test-type.run.stdout @@ -1,6 +1,6 @@ running 3 tests -test test_no_run ... ignored +test test_no_run ... ignored, msg test test_ok ... ok test test_panic - should panic ... ok