aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rw-r--r--bin/qsp_parser.ml18
1 files changed, 18 insertions, 0 deletions
diff --git a/bin/qsp_parser.ml b/bin/qsp_parser.ml
index fef6aac..30c0ac0 100644
--- a/bin/qsp_parser.ml
+++ b/bin/qsp_parser.ml
@@ -22,6 +22,7 @@ let available_checks =
snd @@ Qsp_syntax.Check.build (module Qsp_syntax.Type_of);
snd @@ Qsp_syntax.Check.build (module Qsp_syntax.Dead_end);
snd @@ Qsp_syntax.Check.build (module Qsp_syntax.Nested_strings);
+ snd @@ Qsp_syntax.Check.build (module Qsp_syntax.Locations);
]
let pp_module formatter (module A : Qsp_syntax.S.Analyzer) =
@@ -133,6 +134,12 @@ let () =
let lexer, parameters =
match Filename.extension file_name with
| ".qsrc" ->
+ (* Deactivate the tests which only applies to a global file *)
+ List.iter available_checks ~f:(fun t ->
+ let (module C : Qsp_syntax.S.Analyzer) =
+ Qsp_syntax.Check.get_module t
+ in
+ if C.is_global then C.active := false);
(* The source file are in UTF-8, and we can use the file line number as
we have only a single location. *)
( Sedlexing.Utf8.from_channel ic,
@@ -161,6 +168,17 @@ let () =
with Qparser.Lexer.EOF -> ()
in
+ (* If the parsing was global, extract the result for the whole test *)
+ let global_report = Check.finalize check_context in
+ List.iter global_report ~f:(fun (f_name, report) ->
+ Format.fprintf Format.std_formatter "Location@ %s@;@[%a@]@." f_name
+ Report.pp report;
+
+ match report.Report.level with
+ | Error -> ctx := { !ctx with error_nb = succ !ctx.error_nb }
+ | Warn -> ctx := { !ctx with warn_nb = succ !ctx.warn_nb }
+ | Debug -> ctx := { !ctx with debug_nb = succ !ctx.debug_nb });
+
match (!ctx.error_nb, !ctx.warn_nb) with
| 0, 0 -> (
print_endline "No errors found";