@@ -161,9 +161,9 @@ fn check_unexpected_files(dir: &str, allowed_rust_files: &HashSet<PathBuf>) -> R
161
161
}
162
162
163
163
fn check_exercises_unsolved ( info_file : & InfoFile , cmd_runner : & CmdRunner ) -> Result < ( ) > {
164
- println ! (
165
- "Running all exercises to check that they aren't already solved. This may take a while… \n " ,
166
- ) ;
164
+ let mut stdout = io :: stdout ( ) . lock ( ) ;
165
+ stdout . write_all ( b "Running all exercises to check that they aren't already solved... \n ") ? ;
166
+
167
167
thread:: scope ( |s| {
168
168
let handles = info_file
169
169
. exercises
@@ -180,6 +180,11 @@ fn check_exercises_unsolved(info_file: &InfoFile, cmd_runner: &CmdRunner) -> Res
180
180
} )
181
181
. collect :: < Vec < _ > > ( ) ;
182
182
183
+ let n_handles = handles. len ( ) ;
184
+ write ! ( stdout, "Progress: 0/{n_handles}" ) ?;
185
+ stdout. flush ( ) ?;
186
+ let mut handle_num = 1 ;
187
+
183
188
for ( exercise_name, handle) in handles {
184
189
let Ok ( result) = handle. join ( ) else {
185
190
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
192
197
Ok ( false ) => ( ) ,
193
198
Err ( e) => return Err ( e) ,
194
199
}
200
+
201
+ write ! ( stdout, "\r Progress: {handle_num}/{n_handles}" ) ?;
202
+ stdout. flush ( ) ?;
203
+ handle_num += 1 ;
195
204
}
205
+ stdout. write_all ( b"\n " ) ?;
196
206
197
207
Ok ( ( ) )
198
208
} )
@@ -225,7 +235,9 @@ fn check_solutions(
225
235
info_file : & InfoFile ,
226
236
cmd_runner : & CmdRunner ,
227
237
) -> Result < ( ) > {
228
- println ! ( "Running all solutions. This may take a while…\n " ) ;
238
+ let mut stdout = io:: stdout ( ) . lock ( ) ;
239
+ stdout. write_all ( b"Running all solutions...\n " ) ?;
240
+
229
241
thread:: scope ( |s| {
230
242
let handles = info_file
231
243
. exercises
@@ -261,6 +273,11 @@ fn check_solutions(
261
273
. arg ( "always" )
262
274
. stdin ( Stdio :: null ( ) ) ;
263
275
276
+ let n_handles = handles. len ( ) ;
277
+ write ! ( stdout, "Progress: 0/{n_handles}" ) ?;
278
+ stdout. flush ( ) ?;
279
+ let mut handle_num = 1 ;
280
+
264
281
for ( exercise_info, handle) in info_file. exercises . iter ( ) . zip ( handles) {
265
282
let Ok ( check_result) = handle. join ( ) else {
266
283
bail ! (
@@ -282,15 +299,21 @@ fn check_solutions(
282
299
}
283
300
SolutionCheck :: MissingOptional => ( ) ,
284
301
SolutionCheck :: RunFailure { output } => {
285
- io:: stderr ( ) . lock ( ) . write_all ( & output) ?;
302
+ stdout. write_all ( b"\n \n " ) ?;
303
+ stdout. write_all ( & output) ?;
286
304
bail ! (
287
305
"Running the solution of the exercise {} failed with the error above" ,
288
306
exercise_info. name,
289
307
) ;
290
308
}
291
309
SolutionCheck :: Err ( e) => return Err ( e) ,
292
310
}
311
+
312
+ write ! ( stdout, "\r Progress: {handle_num}/{n_handles}" ) ?;
313
+ stdout. flush ( ) ?;
314
+ handle_num += 1 ;
293
315
}
316
+ stdout. write_all ( b"\n " ) ?;
294
317
295
318
let handle = s. spawn ( move || check_unexpected_files ( "solutions" , & sol_paths) ) ;
296
319
0 commit comments