From 0233bfc9e489bd306475301b69e21e094488a009 Mon Sep 17 00:00:00 2001 From: Jan Midtgaard Date: Mon, 14 Sep 2026 23:37:43 +0200 Subject: [PATCH 1/4] Update test/instrumentation-tests/gadts.t to be 5.2-compatible --- test/instrumentation-tests/gadts.t | 83 +++++++++++++++--------------- 1 file changed, 41 insertions(+), 42 deletions(-) diff --git a/test/instrumentation-tests/gadts.t b/test/instrumentation-tests/gadts.t index 3e2a6c6..5163b08 100644 --- a/test/instrumentation-tests/gadts.t +++ b/test/instrumentation-tests/gadts.t @@ -38,11 +38,10 @@ Check that the example typechecks type _ t = | Int: int t | Bool: bool t - let f (type a) = - (function - | Int -> if __is_mutaml_mutant__ "test:0" then 1 else 0 - | Bool -> if __is_mutaml_mutant__ "test:1" then false else true : - a t -> a) + let f (type a) : a t -> a= + function + | Int -> if __is_mutaml_mutant__ "test:0" then 1 else 0 + | Bool -> if __is_mutaml_mutant__ "test:1" then false else true let () = (f Int) |> (Printf.printf "%i\n") This shouldn't fail. It should just fail to mutate the patterns. @@ -251,13 +250,13 @@ Check that the example typechecks type _ t = | Int: int t | Bool: bool t - let f (type a) = - (function - | [|Int;Int|] when not (__is_mutaml_mutant__ "test:3") -> - if __is_mutaml_mutant__ "test:0" then 1 else 0 - | [|Bool|] when not (__is_mutaml_mutant__ "test:2") -> - if __is_mutaml_mutant__ "test:1" then false else true - | _ -> failwith "ouch" : a t array -> a) + let f (type a) : a t array -> a= + function + | [|Int;Int|] when not (__is_mutaml_mutant__ "test:3") -> + if __is_mutaml_mutant__ "test:0" then 1 else 0 + | [|Bool|] when not (__is_mutaml_mutant__ "test:2") -> + if __is_mutaml_mutant__ "test:1" then false else true + | _ -> failwith "ouch" @@ -308,15 +307,15 @@ Check that the example typechecks | Int: int t | Bool: bool t | Char: char t - let f (type a) = - (function - | [|Int|] -> if __is_mutaml_mutant__ "test:0" then 1 else 0 - | [|Bool|] -> if __is_mutaml_mutant__ "test:1" then false else true - | [|Char|] -> 'c' - | _ when if __is_mutaml_mutant__ "test:2" then false else true -> - failwith "empty" - | _ when if __is_mutaml_mutant__ "test:3" then true else false -> - failwith "dead" : a t array -> a) + let f (type a) : a t array -> a= + function + | [|Int|] -> if __is_mutaml_mutant__ "test:0" then 1 else 0 + | [|Bool|] -> if __is_mutaml_mutant__ "test:1" then false else true + | [|Char|] -> 'c' + | _ when if __is_mutaml_mutant__ "test:2" then false else true -> + failwith "empty" + | _ when if __is_mutaml_mutant__ "test:3" then true else false -> + failwith "dead" File "test.ml", lines 6-11, characters 34-34: 6 | ..................................function 7 | | [| Int |] -> 0 @@ -362,13 +361,13 @@ Check that the example typechecks type _ t = | Int: int t | Bool: bool t - let f (type a) = - (function - | [|_x;Int|] when not (__is_mutaml_mutant__ "test:3") -> - if __is_mutaml_mutant__ "test:0" then 3 else 2 - | [|Bool;_x|] when not (__is_mutaml_mutant__ "test:2") -> - if __is_mutaml_mutant__ "test:1" then false else true - | _ -> failwith "eww" : a t array -> a) + let f (type a) : a t array -> a= + function + | [|_x;Int|] when not (__is_mutaml_mutant__ "test:3") -> + if __is_mutaml_mutant__ "test:0" then 3 else 2 + | [|Bool;_x|] when not (__is_mutaml_mutant__ "test:2") -> + if __is_mutaml_mutant__ "test:1" then false else true + | _ -> failwith "eww" @@ -403,20 +402,20 @@ Check that the example typechecks type _ t = | Int: int t | Bool: bool t - let _f (type a) (type b) = - (function - | (Int, _) when not (__is_mutaml_mutant__ "test:4") -> - if __is_mutaml_mutant__ "test:0" then 1 else 0 - | (_, Bool) when not (__is_mutaml_mutant__ "test:3") -> - if __is_mutaml_mutant__ "test:1" then 0 else 1 - | _ -> if __is_mutaml_mutant__ "test:2" then 3 else 2 : (a t * b t) -> int) - let _f (type a) (type b) = - (function - | (Int, Int) when not (__is_mutaml_mutant__ "test:9") -> - if __is_mutaml_mutant__ "test:5" then 1 else 0 - | (Bool, Bool) when not (__is_mutaml_mutant__ "test:8") -> - if __is_mutaml_mutant__ "test:6" then 0 else 1 - | _ -> if __is_mutaml_mutant__ "test:7" then 3 else 2 : (a t * b t) -> int) + let _f (type a) (type b) : (a t * b t) -> int= + function + | (Int, _) when not (__is_mutaml_mutant__ "test:4") -> + if __is_mutaml_mutant__ "test:0" then 1 else 0 + | (_, Bool) when not (__is_mutaml_mutant__ "test:3") -> + if __is_mutaml_mutant__ "test:1" then 0 else 1 + | _ -> if __is_mutaml_mutant__ "test:2" then 3 else 2 + let _f (type a) (type b) : (a t * b t) -> int= + function + | (Int, Int) when not (__is_mutaml_mutant__ "test:9") -> + if __is_mutaml_mutant__ "test:5" then 1 else 0 + | (Bool, Bool) when not (__is_mutaml_mutant__ "test:8") -> + if __is_mutaml_mutant__ "test:6" then 0 else 1 + | _ -> if __is_mutaml_mutant__ "test:7" then 3 else 2 From c91de48187103d4304dc5d7e9db81b7e4f238e2f Mon Sep 17 00:00:00 2001 From: Jan Midtgaard Date: Mon, 14 Sep 2026 23:43:34 +0200 Subject: [PATCH 2/4] Update test/write_dune_files.sh to silence partial-match failures, settling some 5.2/5.4/5.5 output disagreement --- test/write_dune_files.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/write_dune_files.sh b/test/write_dune_files.sh index 82f13bd..60dc5d0 100755 --- a/test/write_dune_files.sh +++ b/test/write_dune_files.sh @@ -10,6 +10,6 @@ cat > dune < Date: Mon, 14 Sep 2026 23:49:00 +0200 Subject: [PATCH 3/4] Silence a partial-match failure for 5.2-5.5 runtest agreement and promote cram results --- test/instrumentation-tests/gadts.t | 29 ++++++----------------------- test/instrumentation-tests/match.t | 16 +++++----------- 2 files changed, 11 insertions(+), 34 deletions(-) diff --git a/test/instrumentation-tests/gadts.t b/test/instrumentation-tests/gadts.t index 5163b08..9a6d11a 100644 --- a/test/instrumentation-tests/gadts.t +++ b/test/instrumentation-tests/gadts.t @@ -277,18 +277,7 @@ Pattern matching on GADT constructors in arrays: > EOF Check that the example typechecks - $ ocamlc -stop-after typing test.ml - File "test.ml", lines 6-11, characters 34-34: - 6 | ..................................function - 7 | | [| Int |] -> 0 - 8 | | [| Bool |] -> true - 9 | | [| Char |] -> 'c' - 10 | | _ when true (*2*2=2+2*) -> failwith "empty" - 11 | | _ when false -> failwith "dead" - Warning 8 [partial-match]: this pattern-matching is not exhaustive. - Here is an example of a case that is not matched: - [| |] - (However, some guarded clause may match this value.) + $ ocamlc -stop-after typing -w -partial-match test.ml $ export MUTAML_SEED=896745231 $ export MUTAML_GADT=true $ bash ../filter_dune_build.sh ./test.bc --instrument-with mutaml 2>&1 > output.txt @@ -298,6 +287,11 @@ Check that the example typechecks Created 4 mutations of test.ml Writing mutation info to test.muts ERROR MESSAGE + Running mutaml instrumentation on "test.ml" + Randomness seed: 896745231 Mutation rate: 100 GADTs enabled: true + Created 4 mutations of test.ml + Writing mutation info to test.muts + let __MUTAML_MUTANT__ = Stdlib.Sys.getenv_opt "MUTAML_MUTANT" let __is_mutaml_mutant__ m = match __MUTAML_MUTANT__ with @@ -316,17 +310,6 @@ Check that the example typechecks failwith "empty" | _ when if __is_mutaml_mutant__ "test:3" then true else false -> failwith "dead" - File "test.ml", lines 6-11, characters 34-34: - 6 | ..................................function - 7 | | [| Int |] -> 0 - 8 | | [| Bool |] -> true - 9 | | [| Char |] -> 'c' - 10 | | _ when true (*2*2=2+2*) -> failwith "empty" - 11 | | _ when false -> failwith "dead" - Error (warning 8 [partial-match]): this pattern-matching is not exhaustive. - Here is an example of a case that is not matched: - [| |] - (However, some guarded clause may match this value.) diff --git a/test/instrumentation-tests/match.t b/test/instrumentation-tests/match.t index f380db9..edc65f5 100644 --- a/test/instrumentation-tests/match.t +++ b/test/instrumentation-tests/match.t @@ -946,6 +946,11 @@ Another example that would trigger merge-of-consecutive-patterns: Created 6 mutations of test.ml Writing mutation info to test.muts ERROR MESSAGE + Running mutaml instrumentation on "test.ml" + Randomness seed: 896745231 Mutation rate: 100 GADTs enabled: true + Created 6 mutations of test.ml + Writing mutation info to test.muts + let __MUTAML_MUTANT__ = Stdlib.Sys.getenv_opt "MUTAML_MUTANT" let __is_mutaml_mutant__ m = match __MUTAML_MUTANT__ with @@ -959,17 +964,6 @@ Another example that would trigger merge-of-consecutive-patterns: | [|_;_;_|] -> if __is_mutaml_mutant__ "test:3" then 4 else 3 | _ when if __is_mutaml_mutant__ "test:4" then false else true -> if __is_mutaml_mutant__ "test:5" then 1001 else 1000 - File "test.ml", lines 1-6, characters 11-23: - 1 | ...........match x with - 2 | | [| |] -> 0 - 3 | | [| _ |] -> 1 - 4 | | [| _;_ |] -> 2 - 5 | | [| _;_;_ |] -> 3 - 6 | | _ when true -> 1000 - Error (warning 8 [partial-match]): this pattern-matching is not exhaustive. - Here is an example of a case that is not matched: - [| _ ; _ ; _ ; _ |] - (However, some guarded clause may match this value.) From d3c520e404b97beec65ef8fba2dc3a40b77951d0 Mon Sep 17 00:00:00 2001 From: Jan Midtgaard Date: Mon, 14 Sep 2026 23:50:22 +0200 Subject: [PATCH 4/4] Require ocaml.5.2.0 for runtest and regenerate opam file --- dune-project | 2 +- mutaml.opam | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dune-project b/dune-project index 3daa0b8..0157d2f 100644 --- a/dune-project +++ b/dune-project @@ -28,7 +28,7 @@ (tags ("test" "mutation testing")) (depends (ocaml (>= 4.12.0)) - (ocaml (and (< 5.2.0) :with-test)) + (ocaml (and (>= 5.2.0) :with-test)) (ppxlib (>= 0.37.0)) (ppx_deriving_yojson (>= 3.7.0)) stdlib-random diff --git a/mutaml.opam b/mutaml.opam index 6449790..ec5702b 100644 --- a/mutaml.opam +++ b/mutaml.opam @@ -19,7 +19,7 @@ bug-reports: "https://github.com/jmid/mutaml/issues" depends: [ "dune" {>= "3.22"} "ocaml" {>= "4.12.0"} - "ocaml" {< "5.2.0" & with-test} + "ocaml" {>= "5.2.0" & with-test} "ppxlib" {>= "0.37.0"} "ppx_deriving_yojson" {>= "3.7.0"} "stdlib-random"