Show ignore message in console and json output

This commit is contained in:
Antonio Yang 2022-03-04 00:22:15 +08:00 committed by Mark Rousskov
parent f58d51b3c0
commit 14daf47e0a
3 changed files with 36 additions and 6 deletions

View File

@ -118,7 +118,7 @@ pub fn write_log_result(
TestResult::TrIgnored => { TestResult::TrIgnored => {
#[cfg(not(bootstrap))] #[cfg(not(bootstrap))]
if let Some(msg) = ignore_message { if let Some(msg) = ignore_message {
format!("ignored, {msg}") format!("ignored: {msg}")
} else { } else {
"ignored".to_owned() "ignored".to_owned()
} }

View File

@ -121,6 +121,27 @@ fn write_result(
), ),
TestResult::TrIgnored => { 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,
)
}
#[cfg(bootstrap)]
self.write_event("test", desc.name.as_slice(), "ignored", exec_time, stdout, None) self.write_event("test", desc.name.as_slice(), "ignored", exec_time, stdout, None)
} }

View File

@ -45,8 +45,12 @@ pub fn write_failed(&mut self) -> io::Result<()> {
self.write_short_result("FAILED", term::color::RED) self.write_short_result("FAILED", term::color::RED)
} }
pub fn write_ignored(&mut self) -> io::Result<()> { pub fn write_ignored(&mut self, may_message: Option<&'static str>) -> io::Result<()> {
self.write_short_result("ignored", term::color::YELLOW) if let Some(message) = may_message {
self.write_short_result(&format!("ignored, {}", message), term::color::YELLOW)
} else {
self.write_short_result("ignored", term::color::YELLOW)
}
} }
pub fn write_time_failed(&mut self) -> io::Result<()> { pub fn write_time_failed(&mut self) -> io::Result<()> {
@ -59,10 +63,10 @@ pub fn write_bench(&mut self) -> io::Result<()> {
pub fn write_short_result( pub fn write_short_result(
&mut self, &mut self,
result: &str, result: impl AsRef<str>,
color: term::color::Color, color: term::color::Color,
) -> io::Result<()> { ) -> io::Result<()> {
self.write_pretty(result, color) self.write_pretty(result.as_ref(), color)
} }
pub fn write_pretty(&mut self, word: &str, color: term::color::Color) -> io::Result<()> { pub fn write_pretty(&mut self, word: &str, color: term::color::Color) -> io::Result<()> {
@ -214,7 +218,12 @@ fn write_result(
match *result { match *result {
TestResult::TrOk => self.write_ok()?, TestResult::TrOk => self.write_ok()?,
TestResult::TrFailed | TestResult::TrFailedMsg(_) => self.write_failed()?, TestResult::TrFailed | TestResult::TrFailedMsg(_) => self.write_failed()?,
TestResult::TrIgnored => self.write_ignored()?, TestResult::TrIgnored => {
#[cfg(not(bootstrap))]
self.write_ignored(desc.ignore_message)?;
#[cfg(bootstrap)]
self.write_ignored(None)?;
}
TestResult::TrBench(ref bs) => { TestResult::TrBench(ref bs) => {
self.write_bench()?; self.write_bench()?;
self.write_plain(&format!(": {}", fmt_bench_samples(bs)))?; self.write_plain(&format!(": {}", fmt_bench_samples(bs)))?;