Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions ocaml/bin/diff_report.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions ocaml/test/test_diff_report.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Loading