Skip to content

Commit d5ea17c

Browse files
committed
refactor(harness): Track status in Summary
1 parent f6057cf commit d5ea17c

3 files changed

Lines changed: 9 additions & 2 deletions

File tree

crates/libtest2-harness/src/notify/pretty.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ impl<W: std::io::Write> super::Notifier for PrettyRunNotifier<W> {
5252
}
5353
}
5454
Event::CaseComplete(inner) => {
55-
let (s, style) = match inner.status {
55+
let status = self.summary.get_status(&inner.name);
56+
let (s, style) = match status {
5657
Some(RunStatus::Ignored) => ("ignored", IGNORED),
5758
Some(RunStatus::Failed) => ("FAILED", FAILED),
5859
None => ("ok", OK),

crates/libtest2-harness/src/notify/summary.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ pub(crate) struct Summary {
1616
}
1717

1818
impl Summary {
19+
pub(crate) fn get_status(&self, name: &str) -> Option<RunStatus> {
20+
let event = self.status.get(name)?;
21+
event.status
22+
}
23+
1924
pub(crate) fn write_start(&self, writer: &mut dyn std::io::Write) -> std::io::Result<()> {
2025
let s = if self.num_run == 1 { "" } else { "s" };
2126

crates/libtest2-harness/src/notify/terse.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ impl<W: std::io::Write> super::Notifier for TerseRunNotifier<W> {
6969
}
7070
Event::CaseStart(_) => {}
7171
Event::CaseComplete(inner) => {
72-
let (c, style) = match inner.status {
72+
let status = self.summary.get_status(&inner.name);
73+
let (c, style) = match status {
7374
Some(RunStatus::Ignored) => ('i', IGNORED),
7475
Some(RunStatus::Failed) => ('F', FAILED),
7576
None => ('.', OK),

0 commit comments

Comments
 (0)