@@ -47,6 +47,22 @@ let dump_dot exs =
47
47
48
48
let n_processes = ref 1
49
49
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
+
50
66
let print_grader_error exercise = function
51
67
| Ok () -> ()
52
68
| Error (-1 ) -> ()
@@ -59,7 +75,7 @@ let print_grader_error exercise = function
59
75
60
76
let spawn_grader
61
77
dump_outputs dump_reports
62
- ?print_result ?dirname meta ex_dir output_json =
78
+ ?print_result ?dirname id meta ex_dir output_json =
63
79
let rec sleep () =
64
80
if ! n_processes < = 0 then
65
81
Lwt. pause () >> = sleep
@@ -70,15 +86,18 @@ let spawn_grader
70
86
sleep () >> = fun () ->
71
87
Lwt. catch (fun () ->
72
88
read_exercise ex_dir >> = fun exercise ->
89
+ grading_status_add id;
73
90
Grader_cli. grade
74
91
~dump_outputs ~dump_reports ~display_callback: false
75
92
?print_result ?dirname meta exercise output_json
76
93
> |= fun r ->
94
+ grading_status_remove id;
77
95
print_grader_error exercise r;
78
96
incr n_processes;
79
97
r)
80
98
(fun e ->
81
99
incr n_processes;
100
+ grading_status_remove id;
82
101
Printf. eprintf " Grader error: %s\n %!" (Printexc. to_string e);
83
102
Lwt. return (Error 0 ))
84
103
@@ -214,7 +233,7 @@ let main dest_dir =
214
233
if ! n_processes = 1 then
215
234
Lwt_list. map_s,
216
235
fun dump_outputs dump_reports ?print_result ?dirname
217
- meta ex_dir json_path ->
236
+ _id meta ex_dir json_path ->
218
237
read_exercise ex_dir >> = fun exercise ->
219
238
Grader_cli. grade
220
239
~dump_outputs ~dump_reports ~display_callback: true
@@ -236,21 +255,22 @@ let main dest_dir =
236
255
else Lwt. return_unit)
237
256
(Lwt_unix. files_of_directory ex_dir) >> = fun () ->
238
257
if not changed then begin
239
- Format. printf " %-24s (no changes)@." id ;
258
+ Format. eprintf " %-24s (no changes)@." id ;
240
259
Lwt. return_true
241
260
end else begin
242
261
Learnocaml_precompile_exercise. precompile ~exercise_dir: ex_dir
243
262
>> = fun () ->
244
263
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)
246
265
>> = function
247
266
| Ok () ->
248
- Format. printf " %-24s [OK]@." id ;
267
+ Format. eprintf " %-24s [OK]@." id ;
249
268
Lwt. return true
250
269
| Error _ ->
251
- Format. printf " %-24s [FAILED]@." id ;
270
+ Format. eprintf " %-24s [FAILED]@." id ;
252
271
Lwt. return false
253
- end)
272
+ end
273
+ > |= fun r -> grading_status () ; r)
254
274
processes_arguments
255
275
end >> = fun results ->
256
276
Lwt. return (List. for_all ((= ) true ) results))
0 commit comments