diff options
| author | Sébastien Dailly <sebastien@dailly.me> | 2026-03-27 08:48:05 +0100 |
|---|---|---|
| committer | Sébastien Dailly <sebastien@dailly.me> | 2026-03-27 08:48:05 +0100 |
| commit | 830e7c5d27d161b91402414e6ecd49f1ed818bfb (patch) | |
| tree | 448864635d29b1ea66424cbb9e0816fbcf1e1907 /test/tests.ml | |
Initial commit
Diffstat (limited to 'test/tests.ml')
| -rw-r--r-- | test/tests.ml | 50 |
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 |
