Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 69 lines (55 sloc) 2.06 KB
#!/usr/bin/env ocaml
* Usage: $ ospecl ...
* The arguments to ospecl should be source files which define a single value `specs : Spec.t list`.
* The specs from each file will be executed in order and the overall results reported.
#use "topfind"
#require "str"
#require "unix"
#require "ospecl"
open Printf
let specs_of_file filename =
let dir = Filename.dirname filename in
Topdirs.dir_directory dir;
let used = Toploop.use_file Format.std_formatter filename in
if used then
Obj.obj (Toploop.getvalue "specs")
failwith (sprintf "Could not use file %s" filename)
let _ =
let usage_message =
let this_file = (Filename.basename Sys.argv.(0)) in
sprintf "$ %s [options] [spec files]\n" this_file in
let files = ref [] in
let include_dirs = ref [] in
let append_to list_ref value =
list_ref := !list_ref @ [value]
let formatter = ref Ospecl.Handlers.Terminal.progress in
let formatters = [
("p", Ospecl.Handlers.Terminal.progress);
("progress", Ospecl.Handlers.Terminal.progress);
("d", Ospecl.Handlers.Terminal.documentation);
("doc", Ospecl.Handlers.Terminal.documentation);
("documentation", Ospecl.Handlers.Terminal.documentation);
let choose_format f =
formatter := List.assoc f formatters
let color = ref false in
let pattern = ref "" in
Arg.parse (Arg.align [
("-I", Arg.String (append_to include_dirs), "DIRECTORY specify include directory");
("-format", Arg.Symbol (fst (List.split formatters), choose_format), " choose a formatter");
("-color", Arg.Set color, " enable color in the output");
("-example", Arg.Set_string pattern, "PATTERN run examples whose full descriptions match this pattern");
(append_to files)
let handlers = !formatter ~color:!color in
List.iter Topdirs.dir_directory !include_dirs;
let all_specs = List.concat ( specs_of_file !files) in
let filtered = Ospecl.Spec.filter (Str.regexp !pattern) all_specs in
Ospecl.Spec.Exec.execute handlers filtered