Skip to content

Commit 3a0ae49

Browse files
yangantom-ou-se
andcommitted
Refactor after review
Co-authored-by: Mara Bos <m-ou.se@m-ou.se>
1 parent 38b96b9 commit 3a0ae49

File tree

2 files changed

+14
-22
lines changed

2 files changed

+14
-22
lines changed

library/test/src/formatters/json.rs

+11-19
Original file line numberDiff line numberDiff line change
@@ -122,25 +122,17 @@ impl<T: Write> OutputFormatter for JsonFormatter<T> {
122122

123123
TestResult::TrIgnored => {
124124
#[cfg(not(bootstrap))]
125-
if let Some(msg) = desc.ignore_message {
126-
self.write_event(
127-
"test",
128-
desc.name.as_slice(),
129-
"ignored",
130-
exec_time,
131-
stdout,
132-
Some(&*format!(r#""message": "{}""#, EscapedString(msg))),
133-
)
134-
} else {
135-
self.write_event(
136-
"test",
137-
desc.name.as_slice(),
138-
"ignored",
139-
exec_time,
140-
stdout,
141-
None,
142-
)
143-
}
125+
return self.write_event(
126+
"test",
127+
desc.name.as_slice(),
128+
"ignored",
129+
exec_time,
130+
stdout,
131+
desc.ignore_message
132+
.map(|msg| format!(r#""message": "{}""#, EscapedString(msg)))
133+
.as_deref(),
134+
);
135+
144136
#[cfg(bootstrap)]
145137
self.write_event("test", desc.name.as_slice(), "ignored", exec_time, stdout, None)
146138
}

library/test/src/formatters/pretty.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ impl<T: Write> PrettyFormatter<T> {
4545
self.write_short_result("FAILED", term::color::RED)
4646
}
4747

48-
pub fn write_ignored(&mut self, may_message: Option<&'static str>) -> io::Result<()> {
49-
if let Some(message) = may_message {
48+
pub fn write_ignored(&mut self, message: Option<&'static str>) -> io::Result<()> {
49+
if let Some(message) = message {
5050
self.write_short_result(&format!("ignored, {}", message), term::color::YELLOW)
5151
} else {
5252
self.write_short_result("ignored", term::color::YELLOW)
@@ -63,7 +63,7 @@ impl<T: Write> PrettyFormatter<T> {
6363

6464
pub fn write_short_result(
6565
&mut self,
66-
result: impl AsRef<str>,
66+
result: &str,
6767
color: term::color::Color,
6868
) -> io::Result<()> {
6969
self.write_pretty(result.as_ref(), color)

0 commit comments

Comments
 (0)