have infer automatically figure out when `--merge` is needed

Reviewed By: jvillard

Differential Revision: D9942867

fbshipit-source-id: 0652925c1
master
Vincent Siles 6 years ago committed by Facebook Github Bot
parent 66392db8d5
commit 69f8ebaef6

@ -20,4 +20,5 @@ type run_info = {
type t = {
run_sequence: run_info list; (** successive runs that re-used the same results directory *)
results_dir_format: string; (** to check if the versions of the results dir are compatible *)
should_merge_capture: bool; (** add --merge to 'infer analyze' if last command was a capture that needs --merge *)
}

@ -14,7 +14,8 @@ let state0 =
{ run_sequence= []
; results_dir_format=
Printf.sprintf "db_filename: %s\ndb_schema: %s" ResultsDatabase.database_filename
ResultsDatabase.schema_hum }
ResultsDatabase.schema_hum
; should_merge_capture= false }
let state : Runstate_t.t ref = ref state0
@ -66,3 +67,7 @@ let load_and_validate () =
let reset () = state := state0
let set_merge_capture onoff = Runstate_t.(state := {!state with should_merge_capture= onoff})
let get_merge_capture () = !state.Runstate_t.should_merge_capture

@ -10,6 +10,12 @@ open! IStd
val add_run_to_sequence : unit -> unit
(** add an entry with the current run date *)
val set_merge_capture : bool -> unit
(** update the 'merge after capture' smart option *)
val get_merge_capture : unit -> bool
(** fetch the value of the 'merge after capture' smart option *)
val store : unit -> unit
(** save the current state to disk *)

@ -279,6 +279,7 @@ let capture ~changed_files = function
updated_buck_cmd )
else build_cmd ) )
in
if in_buck_mode && Config.flavors then ( RunState.set_merge_capture true ; RunState.store () ) ;
run_command ~prog:infer_py ~args
~cleanup:(function
| Error (`Exit_non_zero exit_code)
@ -394,10 +395,15 @@ let analyze_and_report ?suppress_console_report ~changed_files mode =
| PythonCapture (BBuck, _) when Config.flavors && InferCommand.equal Run Config.command ->
(* if doing capture + analysis of buck with flavors, we always need to merge targets before the analysis phase *)
true
| Analyze ->
RunState.get_merge_capture ()
| _ ->
(* else rely on the command line value *) Config.merge
in
if should_merge then MergeCapture.merge_captured_targets () ;
if should_merge then (
MergeCapture.merge_captured_targets () ;
RunState.set_merge_capture false ;
RunState.store () ) ;
if should_analyze then
if SourceFiles.is_empty () && Config.capture then error_nothing_to_analyze mode
else execute_analyze ~changed_files ;

Loading…
Cancel
Save