summaryrefslogtreecommitdiff
path: root/test/tests.ml
diff options
context:
space:
mode:
Diffstat (limited to 'test/tests.ml')
-rw-r--r--test/tests.ml50
1 files changed, 50 insertions, 0 deletions
diff --git a/test/tests.ml b/test/tests.ml
new file mode 100644
index 0000000..5e2bd59
--- /dev/null
+++ b/test/tests.ml
@@ -0,0 +1,50 @@
+(** 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);
+ ]
+
+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