about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAliƩnore Bouttefeux <alienore.bouttefeux@gmail.com>2021-05-18 18:17:36 +0200
committerAliƩnore Bouttefeux <alienore.bouttefeux@gmail.com>2021-05-18 18:18:28 +0200
commit6de13c3ffc969ceac87f2a8466c5cd850288721c (patch)
treed235f1dded3907fddfb911cbcfb63660a2cc124b
parent3d8180635289437ac96b20ec94419394194f7c83 (diff)
downloadrust-6de13c3ffc969ceac87f2a8466c5cd850288721c.tar.gz
rust-6de13c3ffc969ceac87f2a8466c5cd850288721c.zip
change based on review
-rw-r--r--library/test/src/formatters/pretty.rs7
-rw-r--r--library/test/src/formatters/terse.rs7
-rw-r--r--library/test/src/types.rs20
3 files changed, 17 insertions, 17 deletions
diff --git a/library/test/src/formatters/pretty.rs b/library/test/src/formatters/pretty.rs
index b3efb2c4437..e17fc08a9ae 100644
--- a/library/test/src/formatters/pretty.rs
+++ b/library/test/src/formatters/pretty.rs
@@ -169,11 +169,10 @@ impl<T: Write> PrettyFormatter<T> {
 
     fn write_test_name(&mut self, desc: &TestDesc) -> io::Result<()> {
         let name = desc.padded_name(self.max_name_len, desc.name.padding());
-        let test_mode = desc.test_mode();
-        if test_mode == "" {
-            self.write_plain(&format!("test {} ... ", name))?;
-        } else {
+        if let Some(test_mode) = desc.test_mode() {
             self.write_plain(&format!("test {} - {} ... ", name, test_mode))?;
+        } else {
+            self.write_plain(&format!("test {} ... ", name))?;
         }
 
         Ok(())
diff --git a/library/test/src/formatters/terse.rs b/library/test/src/formatters/terse.rs
index ce73f8d3bfb..a2c223c494c 100644
--- a/library/test/src/formatters/terse.rs
+++ b/library/test/src/formatters/terse.rs
@@ -158,11 +158,10 @@ impl<T: Write> TerseFormatter<T> {
 
     fn write_test_name(&mut self, desc: &TestDesc) -> io::Result<()> {
         let name = desc.padded_name(self.max_name_len, desc.name.padding());
-        let test_mode = desc.test_mode();
-        if test_mode == "" {
-            self.write_plain(&format!("test {} ... ", name))?;
-        } else {
+        if let Some(test_mode) = desc.test_mode() {
             self.write_plain(&format!("test {} - {} ... ", name, test_mode))?;
+        } else {
+            self.write_plain(&format!("test {} ... ", name))?;
         }
 
         Ok(())
diff --git a/library/test/src/types.rs b/library/test/src/types.rs
index baf9908669b..63907c71ea7 100644
--- a/library/test/src/types.rs
+++ b/library/test/src/types.rs
@@ -145,32 +145,34 @@ impl TestDesc {
         }
     }
 
+    /// Returns None for ignored test or that that are just run, otherwise give a description of the type of test.
+    /// Descriptions include "should panic", "compile fail" and "compile".
     #[cfg(not(bootstrap))]
-    pub fn test_mode(&self) -> &'static str {
+    pub fn test_mode(&self) -> Option<&'static str> {
         if self.ignore {
-            return &"";
+            return None;
         }
         match self.should_panic {
             options::ShouldPanic::Yes | options::ShouldPanic::YesWithMessage(_) => {
-                return &"should panic";
+                return Some("should panic");
             }
             options::ShouldPanic::No => {}
         }
         if self.allow_fail {
-            return &"allow fail";
+            return Some("allow fail");
         }
         if self.compile_fail {
-            return &"compile fail";
+            return Some("compile fail");
         }
         if self.no_run {
-            return &"compile";
+            return Some("compile");
         }
-        &""
+        None
     }
 
     #[cfg(bootstrap)]
-    pub fn test_mode(&self) -> &'static str {
-        &""
+    pub fn test_mode(&self) -> Option<&'static str> {
+        None
     }
 }