diff options
Diffstat (limited to 'instrumentation/src/utils.rs')
-rw-r--r-- | instrumentation/src/utils.rs | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/instrumentation/src/utils.rs b/instrumentation/src/utils.rs index 835764a..5509754 100644 --- a/instrumentation/src/utils.rs +++ b/instrumentation/src/utils.rs @@ -16,14 +16,12 @@ use std::{ fmt::Display, - fmt::Write as _, io::Write as _, net::{Ipv4Addr, SocketAddrV4, TcpListener, TcpStream}, ops::{Deref, DerefMut}, path::{Path, PathBuf}, process::{Child, Command, Stdio}, str::FromStr, - sync::{Arc, Mutex}, thread::sleep, time::{Duration, Instant}, }; @@ -35,6 +33,7 @@ use common::{ rand_slice, url::Url, }; +use indicatif::ProgressBar; use signal_child::{signal::Signal, Signalable}; use tempfile::TempDir; @@ -200,11 +199,11 @@ pub fn retry(mut lambda: impl FnMut() -> bool) { #[derive(Clone)] pub struct TestCtx { pub log_dir: String, - pub out: Arc<Mutex<String>>, + pub pb: ProgressBar, } impl TestCtx { - pub fn new(name: &str) -> Self { + pub fn new(name: &str, pb: ProgressBar) -> Self { // Create log dir let log_dir = format!("log/{name}"); std::fs::remove_dir_all(&log_dir).ok(); @@ -213,10 +212,7 @@ impl TestCtx { let pwd: String = (0..30).map(|_| fastrand::alphanumeric()).collect(); std::env::set_var("PASSWORD", pwd); - Self { - log_dir, - out: Arc::new(Mutex::new(String::new())), - } + Self { log_dir, pb } } pub fn log(&self, name: &str) -> String { @@ -224,8 +220,7 @@ impl TestCtx { } pub fn step(&self, disp: impl Display) { - let it: &mut String = &mut self.out.lock().unwrap(); - writeln!(it, "{disp}").unwrap(); + self.pb.set_message(format!("{disp}")) } } @@ -238,7 +233,7 @@ pub struct TalerCtx { pub taler_conf: TalerConfig, ctx: TestCtx, db: ChildGuard, - wire_bin_path: String, + pub wire_bin_path: String, stressed: bool, gateway: Option<ChildGuard>, pub gateway_url: String, |