From 6d1d78bb60cae34c7c6c3102790fc38120080d50 Mon Sep 17 00:00:00 2001 From: Martino Luca Date: Tue, 9 May 2017 14:17:39 -0700 Subject: [PATCH] Change invariant to compute differential of reports Reviewed By: jeremydubreil Differential Revision: D5031092 fbshipit-source-id: f762179 --- infer/src/backend/infer.ml | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/infer/src/backend/infer.ml b/infer/src/backend/infer.ml index f525aee7a..ace774c9f 100644 --- a/infer/src/backend/infer.ml +++ b/infer/src/backend/infer.ml @@ -521,14 +521,18 @@ let infer_mode () = clean_results_dir () let differential_mode () = - let arg_or_fail arg_name arg_opt = - match arg_opt with - | Some arg -> arg - | None -> failwithf "Expected '%s' argument not found" arg_name in - let load_report filename : Jsonbug_t.report = - Jsonbug_j.report_of_string (In_channel.read_all filename) in - let current_report = load_report (arg_or_fail "report-current" Config.report_current) in - let previous_report = load_report (arg_or_fail "report-previous" Config.report_previous) in + (* at least one report must be passed in input to compute differential *) + (match Config.report_current, Config.report_previous with + | None, None -> + failwith "Expected at least one argument among 'report-current' and 'report-previous'\n" + | _ -> ()); + let load_report filename_opt : Jsonbug_t.report = + let empty_report = [] in + Option.value_map + ~f:(fun filename -> Jsonbug_j.report_of_string (In_channel.read_all filename)) + ~default:empty_report filename_opt in + let current_report = load_report Config.report_current in + let previous_report = load_report Config.report_previous in let file_renamings = match Config.file_renamings with | Some f -> DifferentialFilters.FileRenamings.from_json_file f | None -> DifferentialFilters.FileRenamings.empty in