From 830e7c5d27d161b91402414e6ecd49f1ed818bfb Mon Sep 17 00:00:00 2001 From: Sébastien Dailly Date: Fri, 27 Mar 2026 08:48:05 +0100 Subject: Initial commit --- test/tests.ml | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 test/tests.ml (limited to 'test/tests.ml') 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 "@[%a@]@." SubCommand.pp result -- cgit v1.2.3