about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--library/test/src/console.rs2
-rw-r--r--library/test/src/formatters/json.rs21
-rw-r--r--library/test/src/formatters/pretty.rs19
3 files changed, 36 insertions, 6 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..7b039164f48 100644
--- a/library/test/src/formatters/json.rs
+++ b/library/test/src/formatters/json.rs
@@ -121,6 +121,27 @@ impl<T: Write> OutputFormatter for JsonFormatter<T> {
             ),
 
             TestResult::TrIgnored => {
+                #[cfg(not(bootstrap))]
+                if let Some(msg) = desc.ignore_message {
+                    self.write_event(
+                        "test",
+                        desc.name.as_slice(),
+                        "ignored",
+                        exec_time,
+                        stdout,
+                        Some(&*format!(r#""message": "{}""#, EscapedString(msg))),
+                    )
+                } else {
+                    self.write_event(
+                        "test",
+                        desc.name.as_slice(),
+                        "ignored",
+                        exec_time,
+                        stdout,
+                        None,
+                    )
+                }
+                #[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..f05c543498f 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, may_message: Option<&'static str>) -> io::Result<()> {
+        if let Some(message) = may_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<()> {
@@ -59,10 +63,10 @@ impl<T: Write> PrettyFormatter<T> {
 
     pub fn write_short_result(
         &mut self,
-        result: &str,
+        result: impl AsRef<str>,
         color: term::color::Color,
     ) -> io::Result<()> {
-        self.write_pretty(result, color)
+        self.write_pretty(result.as_ref(), color)
     }
 
     pub fn write_pretty(&mut self, word: &str, color: term::color::Color) -> 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)))?;