mirror of
https://github.com/rust-lang/rustlings.git
synced 2024-12-26 15:26:29 +00:00
Show progress of dev check
This commit is contained in:
parent
78a8553f1c
commit
b01fddef8b
1 changed files with 28 additions and 5 deletions
|
@ -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<()> {
|
fn check_exercises_unsolved(info_file: &InfoFile, cmd_runner: &CmdRunner) -> Result<()> {
|
||||||
println!(
|
let mut stdout = io::stdout().lock();
|
||||||
"Running all exercises to check that they aren't already solved. This may take a while…\n",
|
stdout.write_all(b"Running all exercises to check that they aren't already solved...\n")?;
|
||||||
);
|
|
||||||
thread::scope(|s| {
|
thread::scope(|s| {
|
||||||
let handles = info_file
|
let handles = info_file
|
||||||
.exercises
|
.exercises
|
||||||
|
@ -180,6 +180,11 @@ fn check_exercises_unsolved(info_file: &InfoFile, cmd_runner: &CmdRunner) -> Res
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>();
|
.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 {
|
for (exercise_name, handle) in handles {
|
||||||
let Ok(result) = handle.join() else {
|
let Ok(result) = handle.join() else {
|
||||||
bail!("Panic while trying to run the exericse {exercise_name}");
|
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) => (),
|
Ok(false) => (),
|
||||||
Err(e) => return Err(e),
|
Err(e) => return Err(e),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
write!(stdout, "\rProgress: {handle_num}/{n_handles}")?;
|
||||||
|
stdout.flush()?;
|
||||||
|
handle_num += 1;
|
||||||
}
|
}
|
||||||
|
stdout.write_all(b"\n")?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
})
|
})
|
||||||
|
@ -225,7 +235,9 @@ fn check_solutions(
|
||||||
info_file: &InfoFile,
|
info_file: &InfoFile,
|
||||||
cmd_runner: &CmdRunner,
|
cmd_runner: &CmdRunner,
|
||||||
) -> Result<()> {
|
) -> 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| {
|
thread::scope(|s| {
|
||||||
let handles = info_file
|
let handles = info_file
|
||||||
.exercises
|
.exercises
|
||||||
|
@ -261,6 +273,11 @@ fn check_solutions(
|
||||||
.arg("always")
|
.arg("always")
|
||||||
.stdin(Stdio::null());
|
.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) {
|
for (exercise_info, handle) in info_file.exercises.iter().zip(handles) {
|
||||||
let Ok(check_result) = handle.join() else {
|
let Ok(check_result) = handle.join() else {
|
||||||
bail!(
|
bail!(
|
||||||
|
@ -282,7 +299,8 @@ fn check_solutions(
|
||||||
}
|
}
|
||||||
SolutionCheck::MissingOptional => (),
|
SolutionCheck::MissingOptional => (),
|
||||||
SolutionCheck::RunFailure { output } => {
|
SolutionCheck::RunFailure { output } => {
|
||||||
io::stderr().lock().write_all(&output)?;
|
stdout.write_all(b"\n\n")?;
|
||||||
|
stdout.write_all(&output)?;
|
||||||
bail!(
|
bail!(
|
||||||
"Running the solution of the exercise {} failed with the error above",
|
"Running the solution of the exercise {} failed with the error above",
|
||||||
exercise_info.name,
|
exercise_info.name,
|
||||||
|
@ -290,7 +308,12 @@ fn check_solutions(
|
||||||
}
|
}
|
||||||
SolutionCheck::Err(e) => return Err(e),
|
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));
|
let handle = s.spawn(move || check_unexpected_files("solutions", &sol_paths));
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue