@@ -47,6 +47,22 @@ let dump_dot exs =
4747
4848let n_processes = ref 1
4949
50+ let grading_status, grading_status_add, grading_status_remove =
51+ let in_progress = ref [] in
52+ let tty = Unix. isatty Unix. stderr in
53+ let show () =
54+ match ! in_progress with
55+ | [] -> flush stderr
56+ | prog ->
57+ Printf. eprintf " Grading in progress: %s" (String. concat " " prog);
58+ if tty then (flush stderr; prerr_string " \r\027 [K" ) else prerr_newline ()
59+ in
60+ show,
61+ (fun id -> in_progress := ! in_progress @ [id]; show () ),
62+ (fun id ->
63+ in_progress := List. filter (fun x -> not (String. equal x id)) ! in_progress;
64+ show () )
65+
5066let print_grader_error exercise = function
5167 | Ok () -> ()
5268 | Error (-1 ) -> ()
@@ -59,7 +75,7 @@ let print_grader_error exercise = function
5975
6076let spawn_grader
6177 dump_outputs dump_reports
62- ?print_result ?dirname meta ex_dir output_json =
78+ ?print_result ?dirname id meta ex_dir output_json =
6379 let rec sleep () =
6480 if ! n_processes < = 0 then
6581 Lwt. pause () >> = sleep
@@ -70,15 +86,18 @@ let spawn_grader
7086 sleep () >> = fun () ->
7187 Lwt. catch (fun () ->
7288 read_exercise ex_dir >> = fun exercise ->
89+ grading_status_add id;
7390 Grader_cli. grade
7491 ~dump_outputs ~dump_reports ~display_callback: false
7592 ?print_result ?dirname meta exercise output_json
7693 > |= fun r ->
94+ grading_status_remove id;
7795 print_grader_error exercise r;
7896 incr n_processes;
7997 r)
8098 (fun e ->
8199 incr n_processes;
100+ grading_status_remove id;
82101 Printf. eprintf " Grader error: %s\n %!" (Printexc. to_string e);
83102 Lwt. return (Error 0 ))
84103
@@ -214,7 +233,7 @@ let main dest_dir =
214233 if ! n_processes = 1 then
215234 Lwt_list. map_s,
216235 fun dump_outputs dump_reports ?print_result ?dirname
217- meta ex_dir json_path ->
236+ _id meta ex_dir json_path ->
218237 read_exercise ex_dir >> = fun exercise ->
219238 Grader_cli. grade
220239 ~dump_outputs ~dump_reports ~display_callback: true
@@ -236,21 +255,22 @@ let main dest_dir =
236255 else Lwt. return_unit)
237256 (Lwt_unix. files_of_directory ex_dir) >> = fun () ->
238257 if not changed then begin
239- Format. printf " %-24s (no changes)@." id ;
258+ Format. eprintf " %-24s (no changes)@." id ;
240259 Lwt. return_true
241260 end else begin
242261 Learnocaml_precompile_exercise. precompile ~exercise_dir: ex_dir
243262 >> = fun () ->
244263 grade dump_outputs dump_reports
245- ~dirname: ex_dir (Index. find index id) ex_dir (Some json_path)
264+ ~dirname: ex_dir id (Index. find index id) ex_dir (Some json_path)
246265 >> = function
247266 | Ok () ->
248- Format. printf " %-24s [OK]@." id ;
267+ Format. eprintf " %-24s [OK]@." id ;
249268 Lwt. return true
250269 | Error _ ->
251- Format. printf " %-24s [FAILED]@." id ;
270+ Format. eprintf " %-24s [FAILED]@." id ;
252271 Lwt. return false
253- end)
272+ end
273+ > |= fun r -> grading_status () ; r)
254274 processes_arguments
255275 end >> = fun results ->
256276 Lwt. return (List. for_all ((= ) true ) results))
0 commit comments