Skip to content

Commit

Permalink
change based on review
Browse files Browse the repository at this point in the history
  • Loading branch information
ABouttefeux committed May 18, 2021
1 parent 3d81806 commit 6de13c3
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
7 changes: 3 additions & 4 deletions library/test/src/formatters/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
Expand Down
7 changes: 3 additions & 4 deletions library/test/src/formatters/terse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
Expand Down
20 changes: 11 additions & 9 deletions library/test/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down

0 comments on commit 6de13c3

Please sign in to comment.