diff --git a/build_system/clerk_driver.ml b/build_system/clerk_driver.ml index f377c377..2237d103 100644 --- a/build_system/clerk_driver.ml +++ b/build_system/clerk_driver.ml @@ -548,8 +548,11 @@ let[@ocamlformat "disable"] static_base_rules = Nj.rule "out-test" ~command: [ !catala_exe; !test_command; "--plugin-dir="; "-o -"; !catala_flags; - !input; ">"; !output; "2>&1"; - "||"; "true"; + !input; "2>&1"; + "|"; "sed"; + "'s/\"CM0|[a-zA-Z0-9|]*\"/\"CMX|XXXXXXXX|XXXXXXXX|XXXXXXXX\"/g'"; + ">"; !output; + "||"; "true" ] ~description: [""; "test"; !test_id; "⇐"; !input; "(" ^ !test_command ^ ")"]; diff --git a/build_system/clerk_runtest.ml b/build_system/clerk_runtest.ml index d9e7ea04..b9daad31 100644 --- a/build_system/clerk_runtest.ml +++ b/build_system/clerk_runtest.ml @@ -16,6 +16,27 @@ open Catala_utils +let sanitize = + let re_endtest = Re.(compile @@ seq [bol; str "```"]) in + let re_modhash = + Re.( + compile + @@ seq + [ + str "\"CM0|"; + repn xdigit 8 (Some 8); + char '|'; + repn xdigit 8 (Some 8); + char '|'; + repn xdigit 8 (Some 8); + char '"'; + ]) + in + fun str -> + str + |> Re.replace_string re_endtest ~by:"\\```" + |> Re.replace_string re_modhash ~by:"\"CMX|XXXXXXXX|XXXXXXXX|XXXXXXXX\"" + let run_catala_test test_flags catala_exe catala_opts file program args oc = let cmd_in_rd, cmd_in_wr = Unix.pipe ~cloexec:true () in let cmd_out_rd, cmd_out_wr = Unix.pipe ~cloexec:true () in @@ -70,8 +91,9 @@ let run_catala_test test_flags catala_exe catala_opts file program args oc = let out_lines = Seq.of_dispenser (fun () -> In_channel.input_line command_ic) in - Seq.iter (fun line -> - output_string oc line; + Seq.iter + (fun line -> + output_string oc (sanitize line); output_char oc '\n') out_lines; let return_code =