From 7da3a90c819181d2dbc17ce5a46efbc6c37399a0 Mon Sep 17 00:00:00 2001 From: Sam Blackshear Date: Tue, 27 Sep 2016 15:40:45 -0700 Subject: [PATCH] [buck] support continuing analysis after crash when --keep-going is passed Reviewed By: jeremydubreil Differential Revision: D3932892 fbshipit-source-id: f6a6d37 --- infer/lib/python/inferlib/bucklib.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/infer/lib/python/inferlib/bucklib.py b/infer/lib/python/inferlib/bucklib.py index e11d5e0d5..68340f9b1 100644 --- a/infer/lib/python/inferlib/bucklib.py +++ b/infer/lib/python/inferlib/bucklib.py @@ -451,15 +451,21 @@ class Wrapper: self.infer_args = infer_args self.timer.start('Computing library targets') base_cmd, buck_args = parse_buck_command(buck_cmd) + self.buck_args = buck_args self.normalized_targets = get_normalized_targets( buck_args.targets) self.buck_cmd = base_cmd + self.normalized_targets self.timer.stop('%d targets computed', len(self.normalized_targets)) + def _collect_results(self, start_time): + self.timer.start('Collecting results ...') + collect_results(self.infer_args, start_time) + self.timer.stop('Done') + def run(self): temp_files = [] + start_time = time.time() try: - start_time = time.time() logging.info('Starting the analysis') if not os.path.isdir(self.infer_args.infer_out): @@ -478,12 +484,16 @@ class Wrapper: buck_cmd = self.buck_cmd + javac_config subprocess.check_call(buck_cmd) self.timer.stop('Buck finished') - self.timer.start('Collecting results ...') - collect_results(self.infer_args, start_time) - self.timer.stop('Done') + self._collect_results(start_time) return os.EX_OK except KeyboardInterrupt as e: self.timer.stop('Exiting') sys.exit(0) + except subprocess.CalledProcessError as e: + if self.buck_args.keep_going: + print('Buck failed, but continuing analysis because --keep-going was passed') + self._collect_results(start_time) + return os.EX_OK + raise e finally: cleanup(temp_files)