diff options
author | Chimrod <> | 2024-02-03 17:42:16 +0100 |
---|---|---|
committer | Chimrod <> | 2024-02-08 14:16:41 +0100 |
commit | d7a13b0e5d6e746993e67a291376bd79766e0ed1 (patch) | |
tree | 80c621cbdb97ce69fd666a4e8f90f4952d237027 /bin/qsp_parser.ml | |
parent | 6fd720c07e3e361932e01bfbdbe4637c8f610649 (diff) |
Added a new check to ensure that every call to another location points to an existing one
Diffstat (limited to 'bin/qsp_parser.ml')
-rw-r--r-- | bin/qsp_parser.ml | 18 |
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"; |