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

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

@ -110,30 +110,21 @@ let collect_all_summaries root_summaries_dir stacktrace_file stacktraces_dir =
IList.iter process_stacktrace input_output_file_pairs IList.iter process_stacktrace input_output_file_pairs
let crashcontext_epilogue ~in_buck_mode = let crashcontext_epilogue ~in_buck_mode =
(* check whether this is the top-level infer process *) (* if we are the top-level process, then find the output directory and
let top_level_infer = collect all crashcontext summaries under it in a single
(* if the '--buck' option was passed, then this is the top level process crashcontext.json file.
iff the build command starts with 'buck' *) Important: Note that when running under buck, this is not the final
if Config.buck then in_buck_mode infer-out/ directory, but instead it is buck-out/, which contains the
(* otherwise, we assume javac as the build command and thus only one infer output directories for every buck target. *)
process *) let root_summaries_dir = if in_buck_mode then begin
else true in let project_root = match Config.project_root with
if top_level_infer then | Some root -> root
(* if we are the top-level process, then find the output directory and | None -> Filename.dirname Config.results_dir in
collect all crashcontext summaries under it in a single let buck_out = match Config.buck_out with
crashcontext.json file. | Some dir -> dir
Important: Note that when running under buck, this is not the final | None -> "buck-out" in
infer-out/ directory, but instead it is buck-out/, which contains the project_root // buck_out
infer output directories for every buck target. *) end
let root_summaries_dir = if in_buck_mode then begin else Config.results_dir in
let project_root = match Config.project_root with collect_all_summaries
| Some root -> root root_summaries_dir Config.stacktrace Config.stacktraces_dir
| None -> Filename.dirname Config.results_dir in
let buck_out = match Config.buck_out with
| Some dir -> dir
| None -> "buck-out" in
project_root // buck_out
end
else Config.results_dir in
collect_all_summaries
root_summaries_dir Config.stacktrace Config.stacktraces_dir

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