Simplify originator detection

Summary:
This simplifies the determination of whether the current process is the
originator of all the infer sub-processes.

Reviewed By: jvillard

Differential Revision: D3751324

fbshipit-source-id: 5e6dc6b
master
Josh Berdine 8 years ago committed by Facebook Github Bot 6
parent 15b6a8cdd7
commit 377d284cf2

@ -352,9 +352,9 @@ let patterns_of_json_with_key json_key json =
(** The working directory of the initial invocation of infer, to which paths passed as command line
options are relative. *)
let init_work_dir =
let init_work_dir, is_originator =
try
Sys.getenv "INFER_CWD"
(Sys.getenv "INFER_CWD", false)
with Not_found ->
let cwd =
(* Use PWD if it denotes the same inode as ., to try to avoid paths with symlinks resolved *)
@ -372,7 +372,7 @@ let init_work_dir =
Sys.getcwd ()
in
Unix.putenv "INFER_CWD" cwd ;
cwd
(cwd, true)
(** Resolve relative paths passed as command line options, i.e., with respect to the working
directory of the initial invocation of infer. *)

@ -131,6 +131,8 @@ val lazy_dynamic_dispatch : bool
val report_custom_error : bool
val sound_dynamic_dispatch : bool
val is_originator : bool
(** Configuration values specified by command-line options *)

@ -110,15 +110,6 @@ let collect_all_summaries root_summaries_dir stacktrace_file stacktraces_dir =
IList.iter process_stacktrace input_output_file_pairs
let crashcontext_epilogue ~in_buck_mode =
(* check whether this is the top-level infer process *)
let top_level_infer =
(* if the '--buck' option was passed, then this is the top level process
iff the build command starts with 'buck' *)
if Config.buck then in_buck_mode
(* otherwise, we assume javac as the build command and thus only one
process *)
else true in
if top_level_infer then
(* if we are the top-level process, then find the output directory and
collect all crashcontext summaries under it in a single
crashcontext.json file.

@ -117,10 +117,13 @@ let () =
if exit_code = Config.infer_py_argparse_error_exit_code then
(* swallow infer.py argument parsing error *)
Config.print_usage_exit ();
if Config.analyzer = Some Config.Crashcontext then
Crashcontext.crashcontext_epilogue ~in_buck_mode;
if exit_code <> 0 then (
prerr_endline ("Failed to execute: " ^ (String.concat " " (Array.to_list args_py))) ;
exit exit_code
);
if Config.fail_on_bug then fail_on_issue_epilogue ()
if Config.is_originator then (
if Config.analyzer = Some Config.Crashcontext then
Crashcontext.crashcontext_epilogue ~in_buck_mode;
if Config.fail_on_bug then
fail_on_issue_epilogue ();
)

Loading…
Cancel
Save