Compare commits

..

4 commits

Author SHA1 Message Date
Kacper Poneta b02b1dc296
Merge 59e8f70e55 into b01fddef8b 2024-08-20 04:26:11 +01:00
mo8it b01fddef8b Show progress of dev check 2024-08-19 23:52:22 +02:00
mo8it 78a8553f1c "Continue at" quits the list 2024-08-19 23:29:17 +02:00
mo8it b70c1abd7c Update deps 2024-08-19 23:28:53 +02:00
3 changed files with 33 additions and 10 deletions

8
Cargo.lock generated
View file

@ -368,9 +368,9 @@ dependencies = [
[[package]]
name = "libc"
version = "0.2.156"
version = "0.2.158"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a5f43f184355eefb8d17fc948dbecf6c13be3c141f20d834ae842193a448c72a"
checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439"
[[package]]
name = "libredox"
@ -746,9 +746,9 @@ dependencies = [
[[package]]
name = "syn"
version = "2.0.74"
version = "2.0.75"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1fceb41e3d546d0bd83421d3409b1460cc7444cd389341a4c880fe7a042cb3d7"
checksum = "f6af063034fc1935ede7be0122941bafa9bacb949334d090b77ca98b5817c7d9"
dependencies = [
"proc-macro2",
"quote",

View file

@ -161,9 +161,9 @@ fn check_unexpected_files(dir: &str, allowed_rust_files: &HashSet<PathBuf>) -> R
}
fn check_exercises_unsolved(info_file: &InfoFile, cmd_runner: &CmdRunner) -> Result<()> {
println!(
"Running all exercises to check that they aren't already solved. This may take a while…\n",
);
let mut stdout = io::stdout().lock();
stdout.write_all(b"Running all exercises to check that they aren't already solved...\n")?;
thread::scope(|s| {
let handles = info_file
.exercises
@ -180,6 +180,11 @@ fn check_exercises_unsolved(info_file: &InfoFile, cmd_runner: &CmdRunner) -> Res
})
.collect::<Vec<_>>();
let n_handles = handles.len();
write!(stdout, "Progress: 0/{n_handles}")?;
stdout.flush()?;
let mut handle_num = 1;
for (exercise_name, handle) in handles {
let Ok(result) = handle.join() else {
bail!("Panic while trying to run the exericse {exercise_name}");
@ -192,7 +197,12 @@ fn check_exercises_unsolved(info_file: &InfoFile, cmd_runner: &CmdRunner) -> Res
Ok(false) => (),
Err(e) => return Err(e),
}
write!(stdout, "\rProgress: {handle_num}/{n_handles}")?;
stdout.flush()?;
handle_num += 1;
}
stdout.write_all(b"\n")?;
Ok(())
})
@ -225,7 +235,9 @@ fn check_solutions(
info_file: &InfoFile,
cmd_runner: &CmdRunner,
) -> Result<()> {
println!("Running all solutions. This may take a while…\n");
let mut stdout = io::stdout().lock();
stdout.write_all(b"Running all solutions...\n")?;
thread::scope(|s| {
let handles = info_file
.exercises
@ -261,6 +273,11 @@ fn check_solutions(
.arg("always")
.stdin(Stdio::null());
let n_handles = handles.len();
write!(stdout, "Progress: 0/{n_handles}")?;
stdout.flush()?;
let mut handle_num = 1;
for (exercise_info, handle) in info_file.exercises.iter().zip(handles) {
let Ok(check_result) = handle.join() else {
bail!(
@ -282,7 +299,8 @@ fn check_solutions(
}
SolutionCheck::MissingOptional => (),
SolutionCheck::RunFailure { output } => {
io::stderr().lock().write_all(&output)?;
stdout.write_all(b"\n\n")?;
stdout.write_all(&output)?;
bail!(
"Running the solution of the exercise {} failed with the error above",
exercise_info.name,
@ -290,7 +308,12 @@ fn check_solutions(
}
SolutionCheck::Err(e) => return Err(e),
}
write!(stdout, "\rProgress: {handle_num}/{n_handles}")?;
stdout.flush()?;
handle_num += 1;
}
stdout.write_all(b"\n")?;
let handle = s.spawn(move || check_unexpected_files("solutions", &sol_paths));

View file

@ -75,7 +75,7 @@ fn handle_list(app_state: &mut AppState, stdout: &mut StdoutLock) -> Result<()>
}
KeyCode::Char('c') => {
ui_state.selected_to_current_exercise()?;
ui_state = ui_state.with_updated_rows();
break;
}
_ => (),
}