Skip to content

Commit 4282665

Browse files
committed
Properly create immutable entries after tests finish fully
1 parent 0de58fb commit 4282665

File tree

1 file changed

+26
-44
lines changed

1 file changed

+26
-44
lines changed

src/status_emitter.rs

Lines changed: 26 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -194,19 +194,6 @@ enum Msg {
194194
}
195195

196196
impl Text {
197-
fn insert_parent_and_reposition_children(
198-
parent: ProgressBar,
199-
bars: &MultiProgress,
200-
children: &HashMap<String, (ProgressBar, bool)>,
201-
) {
202-
let parent = bars.insert(0, parent);
203-
for (msg, (child, _)) in children.iter() {
204-
if !msg.is_empty() {
205-
bars.remove(child);
206-
bars.insert_after(&parent, child.clone());
207-
}
208-
}
209-
}
210197
fn start_thread(progress: OutputVerbosity) -> Self {
211198
let (sender, receiver) = crossbeam_channel::unbounded();
212199
let handle = std::thread::spawn(move || {
@@ -233,40 +220,34 @@ impl Text {
233220
panic!("pop: {parent}({msg}): {children:#?}")
234221
};
235222
*done = true;
236-
let template = if msg.is_empty() {
237-
"{prefix} {msg}"
238-
} else {
239-
" {prefix} {msg}"
240-
};
223+
let spinner = spinner.clone();
241224

242-
spinner.set_style(ProgressStyle::with_template(template).unwrap());
243225
if let Some(new_msg) = new_msg {
244-
bars.remove(spinner);
245-
let spinner = spinner.clone();
246-
let spinner = if msg.is_empty() {
247-
// insert at the top
248-
Self::insert_parent_and_reposition_children(
249-
spinner.clone(),
250-
&bars,
251-
children,
252-
);
253-
254-
spinner
255-
} else {
256-
let parent = children[""].0.clone();
226+
spinner.finish_with_message(new_msg);
227+
let parent = children[""].0.clone();
228+
if !msg.is_empty() {
257229
parent.inc(1);
258-
if children.values().all(|&(_, done)| done) {
259-
bars.remove(&parent);
260-
Self::insert_parent_and_reposition_children(
261-
parent, &bars, children,
262-
);
263-
spinner
264-
} else {
265-
bars.insert_after(&parent, spinner)
230+
}
231+
if children.values().all(|&(_, done)| done) {
232+
bars.remove(&parent);
233+
bars.println(format!(
234+
"{} {}",
235+
parent.prefix(),
236+
parent.message()
237+
))
238+
.unwrap();
239+
for (msg, (child, _)) in children.iter() {
240+
if !msg.is_empty() {
241+
bars.remove(child);
242+
bars.println(format!(
243+
" {} {}",
244+
child.prefix(),
245+
child.message()
246+
))
247+
.unwrap();
248+
}
266249
}
267-
};
268-
spinner.tick();
269-
spinner.finish_with_message(new_msg);
250+
}
270251
} else {
271252
spinner.finish_and_clear();
272253
}
@@ -335,7 +316,8 @@ impl Text {
335316
}
336317
}
337318
for (key, children) in threads.iter() {
338-
for (sub_key, (_child, done)) in children {
319+
for (sub_key, (child, done)) in children {
320+
child.tick();
339321
assert!(done, "{key} ({sub_key}) not finished");
340322
}
341323
}

0 commit comments

Comments
 (0)