diff options
Diffstat (limited to 'instrumentation/src/main.rs')
-rw-r--r-- | instrumentation/src/main.rs | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/instrumentation/src/main.rs b/instrumentation/src/main.rs index f196d7d..12971ad 100644 --- a/instrumentation/src/main.rs +++ b/instrumentation/src/main.rs @@ -17,7 +17,7 @@ use std::{ panic::catch_unwind, path::PathBuf, - time::{Duration, Instant}, + time::{Duration, Instant}, sync::{Arc, Mutex}, }; use clap::Parser; @@ -110,34 +110,34 @@ pub fn main() { let pb = m.add(ProgressBar::new_spinner()); pb.set_style(start_style.clone()); pb.set_prefix(*name); - pb.set_message("RUN"); + pb.set_message("Init"); pb.enable_steady_tick(Duration::from_millis(1000)); let join = s.spawn(move || { let start = Instant::now(); - let ctx = TestCtx::new(name); - let tmp = ctx.clone(); + let ctx: TestCtx = TestCtx::new(name, pb.clone()); + let out = Arc::new(Mutex::new(String::new())); + let tmp = out.clone(); set_hook(Box::new(move |info| { let mut buf = Vec::new(); color_backtrace::BacktracePrinter::new() .print_panic_info(info, &mut NoColor::new(&mut buf)) .ok(); let str = String::from_utf8(buf).unwrap_or_default(); - tmp.out.lock().unwrap().push_str(&str); + tmp.lock().unwrap().push_str(&str); })); let tmp = ctx.clone(); let result = catch_unwind(|| { action(tmp); }); - let lock = ctx.out.lock().unwrap(); if result.is_ok() { pb.set_style(ok_style.clone()); pb.finish_with_message("OK"); } else { pb.set_style(err_style.clone()); - pb.finish_with_message("ERR"); + pb.finish(); } - - (result, start.elapsed(), lock.clone()) + let out: String = out.lock().unwrap().clone(); + (result, start.elapsed(), out) }); (join, name) }) |