Skip to content

Commit

Permalink
Check ground models with Dolmen
Browse files Browse the repository at this point in the history
  • Loading branch information
Halbaroth committed Aug 10, 2023
1 parent 34ec145 commit fb2202c
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ runtest: gentest bin

# Run non-regression tests for the CI.
runtest-ci: gentest bin
dune build @runtest @runtest-quick @runtest-ci
dune build @runtest @runtest-quick @runtest-ci @check-models

# Promote new outputs of the tests.
promote:
Expand Down
1 change: 1 addition & 0 deletions alt-ergo-lib.opam
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ depends: [
"dolmen" {>= "0.9"}
"dolmen_type" {>= "0.9"}
"dolmen_loop" {>= "0.9"}
"dolmen_bin" {with-test}
"ocplib-simplex" {>= "0.5"}
"zarith" {>= "1.4"}
"seq"
Expand Down
1 change: 1 addition & 0 deletions dune-project
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ See more details on http://alt-ergo.ocamlpro.com/"
(dolmen (>= 0.9))
(dolmen_type (>= 0.9))
(dolmen_loop (>= 0.9))
(dolmen_bin :with-test)
(ocplib-simplex (>= 0.5))
(zarith (>= 1.4))
seq
Expand Down
37 changes: 30 additions & 7 deletions tools/gentest.ml
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,12 @@ end
module Test : sig
type t = private {
cmd: Cmd.t;
pb_file: string
pb_file: string;
check_model: bool;
}
(** Type of a test. *)

val make: cmd: Cmd.t -> pb_file: string -> t
val make: cmd: Cmd.t -> pb_file: string -> check_model: bool -> t
(** Set up the test. *)

val pp_expected_output: t printer
Expand All @@ -124,10 +125,11 @@ module Test : sig
end = struct
type t = {
cmd: Cmd.t;
pb_file: string
pb_file: string;
check_model: bool;
}

let make ~cmd ~pb_file = {cmd; pb_file}
let make ~cmd ~pb_file ~check_model = {cmd; pb_file; check_model}

let pp_output fmt tst =
let filename = Filename.chop_extension tst.pb_file in
Expand All @@ -152,7 +154,8 @@ end = struct
@[<v 1>(ignore-stderr@,\
@[<v 1>(with-accepted-exit-codes 0@,\
@[<v 1>(run %a))))))))@]@]@]@]@]@]@\n\
@[<v 1>(rule@,\
@[<v 1>\
(rule@,\
@[<v 1>(alias %s)@,\
@[<v 1>(package alt-ergo)@,\
@[<v 1>(action (diff %a @, %a)))@]@]@]@]@]@."
Expand All @@ -161,7 +164,23 @@ end = struct
Cmd.pp tst.cmd
(Cmd.group tst.cmd)
pp_expected_output tst
pp_output tst
pp_output tst;
let () =
if tst.check_model then
Format.fprintf fmt "\
@[<v 1>\
(rule@,\
(alias check-models)@,\
(deps (:input %a) (:test %s))@,\
(package alt-ergo)@,\
@[<v 1>(action@,\
@[<v 1>(with-accepted-exit-codes 0@,\
@[<v 1>(bash \"sed 's/^unknown/sat/' %%{input} | \
opam exec -- dolmen --check-model true %%{test}\"))))@]@]@]@]\n@."
pp_output tst
tst.pb_file
in
()
end

module Batch : sig
Expand Down Expand Up @@ -208,7 +227,11 @@ end = struct
in
List.fold_left (fun acc2 cmd ->
if filter ~exclude filters cmd then
Test.make ~cmd ~pb_file :: acc2
let check_model =
List.exists (String.equal "models")
(String.split_on_char '.' pb_file)
in
Test.make ~cmd ~pb_file ~check_model :: acc2
else
acc2
) acc1 cmds) [] pb_files
Expand Down

0 comments on commit fb2202c

Please sign in to comment.