mirror of
https://git.aramjonghu.dev/AramJonghu/rustlings.git
synced 2026-09-03 08:43:30 +02:00
Use os_pipe
This commit is contained in:
+11
-2
@@ -11,7 +11,12 @@ use std::{
|
||||
process::{Command, Stdio},
|
||||
};
|
||||
|
||||
use crate::{embedded::EMBEDDED_FILES, exercise::Exercise, info_file::ExerciseInfo, DEBUG_PROFILE};
|
||||
use crate::{
|
||||
embedded::EMBEDDED_FILES,
|
||||
exercise::{Exercise, OUTPUT_CAPACITY},
|
||||
info_file::ExerciseInfo,
|
||||
DEBUG_PROFILE,
|
||||
};
|
||||
|
||||
const STATE_FILE_NAME: &str = ".rustlings-state.txt";
|
||||
const BAD_INDEX_ERR: &str = "The current exercise index is higher than the number of exercises";
|
||||
@@ -302,11 +307,13 @@ impl AppState {
|
||||
let Some(ind) = self.next_pending_exercise_ind() else {
|
||||
writer.write_all(RERUNNING_ALL_EXERCISES_MSG)?;
|
||||
|
||||
let mut output = Vec::with_capacity(OUTPUT_CAPACITY);
|
||||
for (exercise_ind, exercise) in self.exercises().iter().enumerate() {
|
||||
writer.write_fmt(format_args!("Running {exercise} ... "))?;
|
||||
writer.flush()?;
|
||||
|
||||
if !exercise.run()?.status.success() {
|
||||
let success = exercise.run(&mut output)?;
|
||||
if !success {
|
||||
writer.write_fmt(format_args!("{}\n\n", "FAILED".red()))?;
|
||||
|
||||
self.current_exercise_ind = exercise_ind;
|
||||
@@ -322,6 +329,8 @@ impl AppState {
|
||||
}
|
||||
|
||||
writer.write_fmt(format_args!("{}\n", "ok".green()))?;
|
||||
|
||||
output.clear();
|
||||
}
|
||||
|
||||
writer.execute(Clear(ClearType::All))?;
|
||||
|
||||
Reference in New Issue
Block a user