(** 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 Insert_list); register (module Path); register (module Update); register (module Identifier); ] 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