diff --git a/ocaml/bin/diff_report.ml b/ocaml/bin/diff_report.ml index de8ae41..6398163 100644 --- a/ocaml/bin/diff_report.ml +++ b/ocaml/bin/diff_report.ml @@ -10,8 +10,20 @@ let () = let any = List.fold_left (fun acc f -> - let diverged = Diff_report.bundle_if_divergent ~out_dir f in - if diverged then Printf.eprintf "divergence: %s -> bundle in %s\n" f out_dir; + (* Guard each fixture: a malformed or unreadable one must not raise out of the fold and + abort the whole batch, which would silently lose the divergence bundles for every + later fixture -- exactly when CI needs them. Surface it as a failure (diverged=true) + so the missing comparison forces a non-zero exit instead of disappearing. Matches the + explicit Parse_error/Sys_error handling in verify_replay.ml and replay_snapshot.ml. *) + let diverged = + try + let d = Diff_report.bundle_if_divergent ~out_dir f in + if d then Printf.eprintf "divergence: %s -> bundle in %s\n" f out_dir; + d + with Stream_parser.Parse_error msg | Sys_error msg -> + Printf.eprintf "cannot compare %s: %s\n" f msg; + true + in acc || diverged) false fixtures in diff --git a/ocaml/test/test_diff_report.ml b/ocaml/test/test_diff_report.ml index b869a32..935e8e6 100644 --- a/ocaml/test/test_diff_report.ml +++ b/ocaml/test/test_diff_report.ml @@ -24,4 +24,17 @@ let () = prerr_endline "FAIL: unexpected divergence for stream_seed7.txt"; exit 1); + (* A malformed fixture must raise a catchable Stream_parser.Parse_error, not some other exception: + the diff_report bin relies on catching exactly this (and Sys_error) to guard each fixture in + the batch so one bad file cannot abort the whole run and silently lose later bundles. *) + let bad = Filename.concat out "malformed.txt" in + let oc = open_out bad in + output_string oc "version 1\ncmd reg S0\n" (* no meta line *); + close_out oc; + (match Diff_report.bundle_if_divergent ~out_dir:out bad with + | _ -> + prerr_endline "FAIL: expected Parse_error for malformed fixture"; + exit 1 + | exception Stream_parser.Parse_error _ -> ()); + print_endline "diff_report: all tests passed"