1
Fork 0

change based on review

This commit is contained in:
Aliénore Bouttefeux 2021-05-18 18:17:36 +02:00
parent 3d81806352
commit 6de13c3ffc
3 changed files with 17 additions and 17 deletions

View file

@ -169,11 +169,10 @@ impl<T: Write> PrettyFormatter<T> {
fn write_test_name(&mut self, desc: &TestDesc) -> io::Result<()> { fn write_test_name(&mut self, desc: &TestDesc) -> io::Result<()> {
let name = desc.padded_name(self.max_name_len, desc.name.padding()); let name = desc.padded_name(self.max_name_len, desc.name.padding());
let test_mode = desc.test_mode(); if let Some(test_mode) = desc.test_mode() {
if test_mode == "" {
self.write_plain(&format!("test {} ... ", name))?;
} else {
self.write_plain(&format!("test {} - {} ... ", name, test_mode))?; self.write_plain(&format!("test {} - {} ... ", name, test_mode))?;
} else {
self.write_plain(&format!("test {} ... ", name))?;
} }
Ok(()) Ok(())

View file

@ -158,11 +158,10 @@ impl<T: Write> TerseFormatter<T> {
fn write_test_name(&mut self, desc: &TestDesc) -> io::Result<()> { fn write_test_name(&mut self, desc: &TestDesc) -> io::Result<()> {
let name = desc.padded_name(self.max_name_len, desc.name.padding()); let name = desc.padded_name(self.max_name_len, desc.name.padding());
let test_mode = desc.test_mode(); if let Some(test_mode) = desc.test_mode() {
if test_mode == "" {
self.write_plain(&format!("test {} ... ", name))?;
} else {
self.write_plain(&format!("test {} - {} ... ", name, test_mode))?; self.write_plain(&format!("test {} - {} ... ", name, test_mode))?;
} else {
self.write_plain(&format!("test {} ... ", name))?;
} }
Ok(()) Ok(())

View file

@ -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))] #[cfg(not(bootstrap))]
pub fn test_mode(&self) -> &'static str { pub fn test_mode(&self) -> Option<&'static str> {
if self.ignore { if self.ignore {
return &""; return None;
} }
match self.should_panic { match self.should_panic {
options::ShouldPanic::Yes | options::ShouldPanic::YesWithMessage(_) => { options::ShouldPanic::Yes | options::ShouldPanic::YesWithMessage(_) => {
return &"should panic"; return Some("should panic");
} }
options::ShouldPanic::No => {} options::ShouldPanic::No => {}
} }
if self.allow_fail { if self.allow_fail {
return &"allow fail"; return Some("allow fail");
} }
if self.compile_fail { if self.compile_fail {
return &"compile fail"; return Some("compile fail");
} }
if self.no_run { if self.no_run {
return &"compile"; return Some("compile");
} }
&"" None
} }
#[cfg(bootstrap)] #[cfg(bootstrap)]
pub fn test_mode(&self) -> &'static str { pub fn test_mode(&self) -> Option<&'static str> {
&"" None
} }
} }