Skip to content

Commit 2fb14f5

Browse files
committed
Leave an ... aborted message on all aborted tests
1 parent 513a4fd commit 2fb14f5

File tree

1 file changed

+27
-39
lines changed

1 file changed

+27
-39
lines changed

src/status_emitter.rs

Lines changed: 27 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -188,24 +188,19 @@ impl JoinOnDrop {
188188
}
189189
}
190190

191-
#[derive(Debug)]
192-
enum PopStyle {
193-
Abort,
194-
Replace(String),
195-
}
196-
197191
#[derive(Debug)]
198192
enum Msg {
199193
Pop {
200194
msg: String,
201-
new_leftover_msg: PopStyle,
195+
new_leftover_msg: String,
202196
parent: String,
203197
},
204198
Push {
205199
parent: String,
206200
msg: String,
207201
},
208202
Finish,
203+
Abort,
209204
}
210205

211206
impl Text {
@@ -229,7 +224,7 @@ impl Text {
229224
}
230225

231226
impl ProgressHandler {
232-
fn pop(&mut self, msg: String, new_leftover_msg: PopStyle, parent: String) {
227+
fn pop(&mut self, msg: String, new_leftover_msg: String, parent: String) {
233228
let Some(children) = self.threads.get_mut(&parent) else {
234229
// This can happen when a test was not run at all, because it failed directly during
235230
// comment parsing.
@@ -241,14 +236,7 @@ impl Text {
241236
};
242237
*done = true;
243238
let spinner = spinner.clone();
244-
match new_leftover_msg {
245-
PopStyle::Replace(new_msg) => spinner.finish_with_message(new_msg),
246-
PopStyle::Abort => {
247-
self.aborted = true;
248-
spinner.finish_and_clear();
249-
return;
250-
}
251-
}
239+
spinner.finish_with_message(new_leftover_msg);
252240
let parent = children[""].0.clone();
253241
if children.values().all(|&(_, done)| done) {
254242
self.bars.remove(&parent);
@@ -365,6 +353,7 @@ impl Text {
365353
handler.push(parent, msg);
366354
}
367355
Msg::Finish => break 'outer,
356+
Msg::Abort => handler.aborted = true,
368357
},
369358
// Sender panicked, skip asserts
370359
Err(TryRecvError::Disconnected) => return,
@@ -418,31 +407,30 @@ struct TextTest {
418407

419408
impl TestStatus for TextTest {
420409
fn done(&self, result: &TestResult, aborted: bool) {
421-
let new_leftover_msg = if aborted {
422-
PopStyle::Abort
423-
} else {
424-
let result = match result {
425-
Ok(TestOk::Ok) => "ok".green(),
426-
Err(Errored { .. }) => "FAILED".bright_red().bold(),
427-
Ok(TestOk::Ignored) => "ignored (in-test comment)".yellow(),
428-
};
429-
let msg = format!("... {result}");
430-
if ProgressDrawTarget::stdout().is_hidden() {
431-
match self.style {
432-
RevisionStyle::Separate => println!("{} {msg}", self.revision),
433-
RevisionStyle::Show => {
434-
let revision = if self.revision.is_empty() {
435-
String::new()
436-
} else {
437-
format!(" (revision `{}`)", self.revision)
438-
};
439-
println!("{}{revision} {msg}", display(&self.path));
440-
}
410+
if aborted {
411+
self.text.sender.send(Msg::Abort).unwrap();
412+
}
413+
let result = match result {
414+
_ if aborted => "aborted".white(),
415+
Ok(TestOk::Ok) => "ok".green(),
416+
Err(Errored { .. }) => "FAILED".bright_red().bold(),
417+
Ok(TestOk::Ignored) => "ignored (in-test comment)".yellow(),
418+
};
419+
let new_leftover_msg = format!("... {result}");
420+
if ProgressDrawTarget::stdout().is_hidden() {
421+
match self.style {
422+
RevisionStyle::Separate => println!("{} {new_leftover_msg}", self.revision),
423+
RevisionStyle::Show => {
424+
let revision = if self.revision.is_empty() {
425+
String::new()
426+
} else {
427+
format!(" (revision `{}`)", self.revision)
428+
};
429+
println!("{}{revision} {new_leftover_msg}", display(&self.path));
441430
}
442-
std::io::stdout().flush().unwrap();
443431
}
444-
PopStyle::Replace(msg)
445-
};
432+
std::io::stdout().flush().unwrap();
433+
}
446434
self.text
447435
.sender
448436
.send(Msg::Pop {

0 commit comments

Comments
 (0)