From 951826e6b59ac930393c88c74f89c35fabb9fe8f Mon Sep 17 00:00:00 2001 From: himanshu soni Date: Tue, 3 Jan 2023 23:54:01 +0930 Subject: [PATCH] fix(verify): progress bar proportion now updates with the number of files verified --- src/verify.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/verify.rs b/src/verify.rs index 97471b8..cf319e4 100644 --- a/src/verify.rs +++ b/src/verify.rs @@ -13,13 +13,15 @@ pub fn verify<'a>( progress: (usize, usize), verbose: bool, ) -> Result<(), &'a Exercise> { - let (num_done, total) = progress; + let (mut num_done, total) = progress; let bar = ProgressBar::new(total as u64); bar.set_style(ProgressStyle::default_bar() .template("Progress: [{bar:60.green/red}] {pos}/{len} {msg}") .progress_chars("#>-") ); bar.set_position(num_done as u64); + bar.set_message(format!("({:.1} %)", 0.)); + for exercise in exercises { let compile_result = match exercise.mode { Mode::Test => compile_and_test(exercise, RunMode::Interactive, verbose), @@ -29,9 +31,10 @@ pub fn verify<'a>( if !compile_result.unwrap_or(false) { return Err(exercise); } + num_done += 1; let percentage = num_done as f32 / total as f32 * 100.0; - bar.set_message(format!("({:.1} %)", percentage)); bar.inc(1); + bar.set_message(format!("({:.1} %)", percentage)); } Ok(()) }