[driver] small refactor to share more code

Summary: It makes sense to run the same prelude and epilogue for `infer analyze` as for `infer run`.

Reviewed By: da319

Differential Revision: D7639363

fbshipit-source-id: 26170c1
master
Jules Villard 7 years ago committed by Facebook Github Bot
parent 16988b0a7a
commit 9a56e7485e

@ -130,7 +130,9 @@ let () =
F.fprintf fmt "of cluster %s" (Filename.basename cluster) F.fprintf fmt "of cluster %s" (Filename.basename cluster)
in in
L.environment_info "Starting analysis %a" pp_cluster_opt Config.cluster_cmdline ; L.environment_info "Starting analysis %a" pp_cluster_opt Config.cluster_cmdline ;
Driver.analyze_and_report Analyze ~changed_files:(Driver.read_config_changed_files ()) run Driver.Analyze
| Capture | Compile | Run ->
run (Lazy.force Driver.mode_from_command_line)
| Report -> | Report ->
InferPrint.main ~report_json:None InferPrint.main ~report_json:None
| ReportDiff -> | ReportDiff ->
@ -143,8 +145,6 @@ let () =
() ) ; () ) ;
ReportDiff.reportdiff ~current_report:Config.report_current ReportDiff.reportdiff ~current_report:Config.report_current
~previous_report:Config.report_previous ~previous_report:Config.report_previous
| Capture | Compile | Run ->
run (Lazy.force Driver.mode_from_command_line)
| Diff -> | Diff ->
Diff.diff (Lazy.force Driver.mode_from_command_line) Diff.diff (Lazy.force Driver.mode_from_command_line)
| Explore when Config.procedures -> | Explore when Config.procedures ->

@ -543,6 +543,7 @@ let run_prologue mode =
L.environment_info "%a@\n" Config.pp_version () ; L.environment_info "%a@\n" Config.pp_version () ;
PerfStats.register_report_at_exit PerfStats.Driver ) ; PerfStats.register_report_at_exit PerfStats.Driver ) ;
if Config.debug_mode then L.environment_info "Driver mode:@\n%a@." pp_mode mode ; if Config.debug_mode then L.environment_info "Driver mode:@\n%a@." pp_mode mode ;
if CLOpt.is_originator then (
if Config.dump_duplicate_symbols then reset_duplicates_file () ; if Config.dump_duplicate_symbols then reset_duplicates_file () ;
(* infer might be called from a Makefile and itself uses `make` to run the analysis in parallel, (* infer might be called from a Makefile and itself uses `make` to run the analysis in parallel,
but cannot communicate with the parent make command. Since infer won't interfere with them but cannot communicate with the parent make command. Since infer won't interfere with them
@ -550,7 +551,7 @@ let run_prologue mode =
mono-threaded execution. *) mono-threaded execution. *)
Unix.unsetenv "MAKEFLAGS" ; Unix.unsetenv "MAKEFLAGS" ;
(* disable the Buck daemon as changes in the Buck or infer config may be missed otherwise *) (* disable the Buck daemon as changes in the Buck or infer config may be missed otherwise *)
Unix.putenv ~key:"NO_BUCKD" ~data:"1" ; Unix.putenv ~key:"NO_BUCKD" ~data:"1" ) ;
() ()
@ -560,7 +561,8 @@ let run_epilogue mode =
if Config.developer_mode then StatsAggregator.generate_files () ; if Config.developer_mode then StatsAggregator.generate_files () ;
if Config.equal_analyzer Config.analyzer Config.Crashcontext then if Config.equal_analyzer Config.analyzer Config.Crashcontext then
Crashcontext.crashcontext_epilogue ~in_buck_mode ; Crashcontext.crashcontext_epilogue ~in_buck_mode ;
if Config.fail_on_bug then fail_on_issue_epilogue () ) ; if Config.fail_on_bug then fail_on_issue_epilogue () ;
() ) ;
if Config.buck_cache_mode then clean_results_dir () ; if Config.buck_cache_mode then clean_results_dir () ;
() ()

Loading…
Cancel
Save