Skip to content

Commit

Permalink
[test] add SKIP variable
Browse files Browse the repository at this point in the history
  • Loading branch information
gares committed Mar 22, 2022
1 parent 54ad167 commit c581d2f
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 7 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ tests:
--sources=$(PWD)/tests/sources/ \
--plot=$(PWD)/tests/plot \
$(addprefix --name-match ,$(ONLY)) \
$(addprefix --cat-skip ,$(SKIP)) \
$(addprefix --runner , $(RUNNERS))

git/%:
Expand Down
2 changes: 1 addition & 1 deletion elpi.opam
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ bug-reports: "https://github.com/LPCIC/elpi/issues"
build: [
["dune" "subst"] {dev}
[make "build" "DUNE_OPTS=-p %{name}% -j %{jobs}%"]
[make "tests" "DUNE_OPTS=-p %{name}%" "TIMEOUT=240"] {with-test & os != "macos" & os-distribution != "alpine" & os-distribution != "freebsd"}
[make "tests" "DUNE_OPTS=-p %{name}%" "SKIP='performance_HO performance_FO'"] {with-test & os != "macos" & os-distribution != "alpine" & os-distribution != "freebsd"}
]

depends: [
Expand Down
5 changes: 3 additions & 2 deletions tests/suite/suite.ml
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,10 @@ let declare
module SM = Map.Make(String)
module SS = Set.Make(String)

let get filter =
let get ~catskip filter =
let filtercat x = List.exists ((=) x) catskip in
let alltests = List.fold_left (fun acc ({ name; _ } as t) -> SM.add name t acc ) SM.empty !tests in
let tests = List.filter (fun { name; _ } -> filter ~name) !tests in
let tests = List.filter (fun { name; category; _ } -> not (filtercat category) && filter ~name) !tests in
let testset = List.fold_left (fun acc { name; _ } -> SS.add name acc ) SS.empty tests in
let deps = List.fold_left (fun acc { after; _ } -> List.fold_right SS.add after acc ) SS.empty tests in
let to_add = SS.fold (fun n acc -> if SS.mem n testset then acc else SS.add n acc) deps SS.empty in
Expand Down
2 changes: 1 addition & 1 deletion tests/suite/suite.mli
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ type t = {
trace: string list;
}

val get : (name:string -> bool) -> t list
val get : catskip:string list -> (name:string -> bool) -> t list

val names : unit -> (string * string list) list (* grouped by category *)

Expand Down
17 changes: 14 additions & 3 deletions tests/test.real.ml
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,14 @@ let rec find_map f = function
| Some y -> y
| None -> find_map f xs

let main sources plot timeout executables namef timetool seed =
let main sources plot timeout executables namef catskip timetool seed =
Random.init seed;
let filter_name =
let rex = Str.regexp (".*"^namef) in
fun ~name:x -> Str.string_match rex x 0 in
let cruft = "CRUFT="^ String.make (Random.bits () mod (2 lsl 16)) 'x' in
let env = Array.concat [[|cruft|];Unix.environment ()] in
let tests = Suite.Test.get filter_name in
let tests = Suite.Test.get ~catskip filter_name in
Printer.print_header ~executables ~seed ~timeout;
let jobs =
tests |> List.map (Suite.Runner.jobs ~timetool ~executables)
Expand Down Expand Up @@ -166,10 +166,21 @@ let runners =
let doc = "Run tests against $(docv)." in
Arg.(non_empty & opt_all non_dir_file [] & info ["runner"] ~docv:"RUNNER" ~doc)

let valid_category_parser c =
if List.exists (fun (c',_) -> c = c') (Test.names ())
then `Ok c
else `Error ("unknown category " ^ c)

let valid_category = Arg.(valid_category_parser,conv_printer string)

let namef =
let doc = "Run only tests with a name that matches $(docv)." in
Arg.(value & opt string "." & info ["name-match"] ~docv:"REX" ~doc)

let catskip =
let doc = "Skip tests belonging to category $(docv)." in
Arg.(value & opt_all valid_category [] & info ["cat-skip"] ~docv:"STRING" ~doc)

let seed =
let doc = "Uses $(docv) as the random number generator seed." in
Arg.(value & opt int 0 & info ["seed"] ~docv:"INT" ~doc)
Expand Down Expand Up @@ -200,4 +211,4 @@ let info =
;;

let () =
Term.exit @@ Term.eval (Term.(const main $ src $ plot $ timeout $ runners $ namef $ mem $ seed), info)
Term.exit @@ Term.eval (Term.(const main $ src $ plot $ timeout $ runners $ namef $ catskip $ mem $ seed), info)

0 comments on commit c581d2f

Please sign in to comment.