aboutsummaryrefslogtreecommitdiff
path: root/bin/args.ml
diff options
context:
space:
mode:
Diffstat (limited to 'bin/args.ml')
-rw-r--r--bin/args.ml49
1 files changed, 45 insertions, 4 deletions
diff --git a/bin/args.ml b/bin/args.ml
index 0021b34..a98981c 100644
--- a/bin/args.ml
+++ b/bin/args.ml
@@ -1,3 +1,4 @@
+open StdLabels
module Report = Qsp_syntax.Report
let input_files = ref []
@@ -23,7 +24,25 @@ let level : string -> unit =
print_endline e;
exit 1
-let speclist printer =
+let disable_module modules identifier =
+ let identifier =
+ String.sub identifier ~pos:1 ~len:(String.length identifier - 1)
+ in
+ List.iter modules ~f:(fun t ->
+ let (module C : Qsp_syntax.S.Analyzer) = Qsp_syntax.Check.get_module t in
+ if String.equal C.identifier identifier then C.active := false)
+
+let enable_module modules identifier =
+ let identifier =
+ String.sub identifier ~pos:1 ~len:(String.length identifier - 1)
+ in
+ List.iter modules ~f:(fun t ->
+ let (module C : Qsp_syntax.S.Analyzer) = Qsp_syntax.Check.get_module t in
+ if String.equal C.identifier identifier then C.active := true)
+
+let speclist modules printer =
+ ignore modules;
+
let common_arguments =
[
( "--version",
@@ -45,6 +64,8 @@ let speclist printer =
Arg.Set reset_line,
"\tEach line is refered from the begining of the file and not the \
location" );
+ ("-<test>", Arg.String anon_fun, "\tDisable this test");
+ ("+<test>", Arg.Unit (fun () -> ()), "\tEnable this test");
]
and windows_arguments =
match Sys.os_type with
@@ -54,9 +75,29 @@ let speclist printer =
in
common_arguments @ windows_arguments
-let parse : list_tests:(Format.formatter -> unit) -> string list * t =
- fun ~list_tests ->
- let speclist = speclist list_tests in
+let parse :
+ modules:Qsp_syntax.Check.t list ->
+ list_tests:(Format.formatter -> unit) ->
+ string list * t =
+ fun ~modules ~list_tests ->
+ let speclist = speclist modules list_tests in
+ let speclist =
+ let r = ref speclist in
+ for i = 1 to pred (Array.length Sys.argv) do
+ let s = Sys.argv.(i) in
+ if
+ s.[0] = '-'
+ && not (List.exists !r ~f:(fun (s', _, _) -> String.equal s s'))
+ then
+ r :=
+ ( s,
+ Arg.Unit (fun () -> disable_module modules s),
+ "\tDisable this test" )
+ :: !r
+ else if s.[0] = '+' then enable_module modules s
+ done;
+ !r
+ in
let () = Arg.parse (Arg.align speclist) anon_fun usage in
match !input_files with