Skip to content

Commit

Permalink
Refactor after review
Browse files Browse the repository at this point in the history
Co-authored-by: Mara Bos <[email protected]>
  • Loading branch information
yanganto and m-ou-se committed Mar 29, 2022
1 parent 38b96b9 commit 3a0ae49
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 22 deletions.
30 changes: 11 additions & 19 deletions library/test/src/formatters/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,25 +122,17 @@ 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,
)
}
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)
}
Expand Down
6 changes: 3 additions & 3 deletions library/test/src/formatters/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ impl<T: Write> PrettyFormatter<T> {
self.write_short_result("FAILED", term::color::RED)
}

pub fn write_ignored(&mut self, may_message: Option<&'static str>) -> io::Result<()> {
if let Some(message) = may_message {
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)
Expand All @@ -63,7 +63,7 @@ impl<T: Write> PrettyFormatter<T> {

pub fn write_short_result(
&mut self,
result: impl AsRef<str>,
result: &str,
color: term::color::Color,
) -> io::Result<()> {
self.write_pretty(result.as_ref(), color)
Expand Down

0 comments on commit 3a0ae49

Please sign in to comment.