blob: d396ac000b2976e7b15f1605e3161aa85916b78d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
(** Test library entry point.
This library is a companion for the CRAM tests exopsing functions for the
test.
Each module can be executed by giving its name as an argument to the binary.
The arguments expected by each test module are not specified *)
let submodule = ref None
let speclist = ref []
let register : (module Intf.T) -> string * Arg.spec * string =
fun (module T) ->
let name =
T.name |> String.lowercase_ascii |> Filename.remove_extension
|> Filename.basename
in
( "--" ^ name,
Arg.Unit
(fun () ->
speclist := T.speclist ();
submodule := Some (module T : Intf.T)),
T.description )
(** Register all the tests in the library *)
let () =
speclist :=
List.sort
(fun (n1, _, _) (n2, _, _) -> String.compare n1 n2)
[
register (module Splay_tree);
register (module Parent);
register (module Schema);
register (module Hash);
register (module Configuration_);
register (module Insert);
register (module Update);
]
let args = ref []
let annon_fun arg = args := arg :: !args
let () = Arg.parse_dynamic speclist annon_fun "Start the tests"
let () =
match !submodule with
| None ->
prerr_endline "Please select a test from the library to run";
exit 1
| Some (module SubCommand : Intf.T) ->
let result = SubCommand.exec !args in
Format.printf "@[<v 0>%a@]@." SubCommand.pp result
|