From 4b9a1162eee3778529be6ee4199f46b749f4b1e3 Mon Sep 17 00:00:00 2001 From: Andre Maroneze <andre.maroneze@cea.fr> Date: Mon, 1 Feb 2021 18:37:52 +0100 Subject: [PATCH] [Report] use Filepath parameters for relevant options --- src/plugins/report/classify.ml | 10 +++++----- src/plugins/report/csv.ml | 9 ++++++--- src/plugins/report/report_parameters.ml | 25 ++++++++++++++---------- src/plugins/report/report_parameters.mli | 10 +++++----- 4 files changed, 31 insertions(+), 23 deletions(-) diff --git a/src/plugins/report/classify.ml b/src/plugins/report/classify.ml index 1c6c22f3d64..f78b7a4c99b 100644 --- a/src/plugins/report/classify.ml +++ b/src/plugins/report/classify.ml @@ -520,14 +520,14 @@ let report_dump fmt = end let report_output file = - R.feedback "Output %s@." file ; - Command.print_file file report_dump + R.feedback "Output %a@." Filepath.Normalized.pretty file; + Command.print_file (file:>string) report_dump let report_number name nb opt = if nb > 0 then R.feedback "%s%4d" name nb ; let file = opt () in - if file <> "" then - let out = open_out file in + if not (Filepath.Normalized.is_unknown file) then + let out = open_out (file:>string) in output_string out (string_of_int nb) ; flush out ; close_out out @@ -541,7 +541,7 @@ let classify () = not (R.Output.is_set ())) then report_console () ; let file = R.Output.get () in - if file <> "" then report_output file ; + if not (Filepath.Normalized.is_unknown file) then report_output file ; report_number "Reviews : " !nb_reviews R.OutputReviews.get ; report_number "Errors : " !nb_errors R.OutputErrors.get ; report_number "Unclassified: " !nb_unclassified R.OutputUnclassified.get ; diff --git a/src/plugins/report/csv.ml b/src/plugins/report/csv.ml index bd6becb61a8..f35afcec625 100644 --- a/src/plugins/report/csv.ml +++ b/src/plugins/report/csv.ml @@ -95,8 +95,9 @@ let print_csv = let print_csv_once () = let file = Report_parameters.CSVFile.get () in - Report_parameters.feedback "Dumping properties in '%s'" file; - print_csv file + Report_parameters.feedback "Dumping properties in '%a'" + Filepath.Normalized.pretty file; + print_csv (file:>string) let print_csv, _ = State_builder.apply_once @@ -107,7 +108,9 @@ let print_csv, _ = Property_status.self ] print_csv_once -let main () = if Report_parameters.CSVFile.get () <> "" then print_csv () +let main () = + if not (Filepath.Normalized.is_unknown (Report_parameters.CSVFile.get ())) + then print_csv () let () = Db.Main.extend main diff --git a/src/plugins/report/report_parameters.ml b/src/plugins/report/report_parameters.ml index b7f24343af6..da18d1ca076 100644 --- a/src/plugins/report/report_parameters.ml +++ b/src/plugins/report/report_parameters.ml @@ -73,11 +73,12 @@ module Proven = let () = Parameter_customize.set_group printing module CSVFile = - String + Filepath (struct let option_name = "-report-csv" let arg_name = "name" - let default = "" + let file_kind = "CSV" + let existence = Fc_Filepath.Indifferent let help = "if set, output properties as a csv file of the given name" end) @@ -166,12 +167,13 @@ module InvalidStatus = let () = Parameter_customize.set_group monitoring module Output = - String + Filepath (struct let option_name = "-report-output" let arg_name = "*.json" + let file_kind = "JSON" + let existence = Fc_Filepath.Indifferent let help = "Output -report-classify in JSON format" - let default = "" end) let () = Parameter_customize.set_group monitoring @@ -184,32 +186,35 @@ module AbsolutePath = let () = Parameter_customize.set_group monitoring module OutputReviews = - String + Filepath (struct let option_name = "-report-output-reviews" let arg_name = "file" + let file_kind = "Text" + let existence = Fc_Filepath.Indifferent let help = "Output number of reviews to <file>" - let default = "" end) let () = Parameter_customize.set_group monitoring module OutputErrors = - String + Filepath (struct let option_name = "-report-output-errors" let arg_name = "file" + let file_kind = "Text" + let existence = Fc_Filepath.Indifferent let help = "Output number of errors to <file>" - let default = "" end) let () = Parameter_customize.set_group monitoring module OutputUnclassified = - String + Filepath (struct let option_name = "-report-output-unclassified" let arg_name = "file" + let file_kind = "Text" + let existence = Fc_Filepath.Indifferent let help = "Output number of unclassified to <file>" - let default = "" end) let () = Parameter_customize.set_group monitoring diff --git a/src/plugins/report/report_parameters.mli b/src/plugins/report/report_parameters.mli index 0f806eeed28..80602986b49 100644 --- a/src/plugins/report/report_parameters.mli +++ b/src/plugins/report/report_parameters.mli @@ -29,7 +29,7 @@ module Untried: Parameter_sig.Bool module Specialized: Parameter_sig.Bool module Proven: Parameter_sig.Bool -module CSVFile: Parameter_sig.String +module CSVFile: Parameter_sig.Filepath module Classify: Parameter_sig.Bool module Rules: Parameter_sig.String_list module Warning: Parameter_sig.String @@ -39,10 +39,10 @@ module UntriedStatus: Parameter_sig.String module UnknownStatus: Parameter_sig.String module InvalidStatus: Parameter_sig.String -module Output: Parameter_sig.String -module OutputReviews: Parameter_sig.String -module OutputErrors: Parameter_sig.String -module OutputUnclassified: Parameter_sig.String +module Output: Parameter_sig.Filepath +module OutputReviews: Parameter_sig.Filepath +module OutputErrors: Parameter_sig.Filepath +module OutputUnclassified: Parameter_sig.Filepath module AbsolutePath: Parameter_sig.Bool module Stdout: Parameter_sig.Bool module Stderr: Parameter_sig.Bool -- GitLab