diff options
| author | bors <bors@rust-lang.org> | 2022-03-29 15:18:57 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-03-29 15:18:57 +0000 |
| commit | 05d22212e89588e7c443cc6b9bc0e4e02fdfbc8d (patch) | |
| tree | 830964c1ab4da553b40547027e81f0ca8a23156b /library | |
| parent | 11909e3588319235e28e99294e17cca11db1d7e2 (diff) | |
| parent | b1c3494d88548222b7af7e8309a5446ea474319e (diff) | |
Auto merge of #94566 - yanganto:show-ignore-message, r=m-ou-se
Show ignore message in console and json output - Provide ignore the message in console and JSON output - Modify the ignore message style in the log file related: #92714
Diffstat (limited to 'library')
| -rw-r--r-- | library/test/src/console.rs | 2 | ||||
| -rw-r--r-- | library/test/src/formatters/json.rs | 13 | ||||
| -rw-r--r-- | library/test/src/formatters/pretty.rs | 15 |
3 files changed, 26 insertions, 4 deletions
diff --git a/library/test/src/console.rs b/library/test/src/console.rs index c7e8507113e..56eef8314fb 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 c089bfc4791..737921c1e10 100644 --- a/library/test/src/formatters/json.rs +++ b/library/test/src/formatters/json.rs @@ -121,6 +121,19 @@ impl<T: Write> OutputFormatter for JsonFormatter<T> { ), 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 f55d390aa56..9b407df2190 100644 --- a/library/test/src/formatters/pretty.rs +++ b/library/test/src/formatters/pretty.rs @@ -45,8 +45,12 @@ impl<T: Write> PrettyFormatter<T> { 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<T: Write> OutputFormatter for PrettyFormatter<T> { 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)))?; |
