[buck] support continuing analysis after crash when --keep-going is passed

Reviewed By: jeremydubreil

Differential Revision: D3932892

fbshipit-source-id: f6a6d37
master
Sam Blackshear 8 years ago committed by Facebook Github Bot 3
parent 967532ea2e
commit 7da3a90c81

@ -451,15 +451,21 @@ class Wrapper:
self.infer_args = infer_args self.infer_args = infer_args
self.timer.start('Computing library targets') self.timer.start('Computing library targets')
base_cmd, buck_args = parse_buck_command(buck_cmd) base_cmd, buck_args = parse_buck_command(buck_cmd)
self.buck_args = buck_args
self.normalized_targets = get_normalized_targets( self.normalized_targets = get_normalized_targets(
buck_args.targets) buck_args.targets)
self.buck_cmd = base_cmd + self.normalized_targets self.buck_cmd = base_cmd + self.normalized_targets
self.timer.stop('%d targets computed', len(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): def run(self):
temp_files = [] temp_files = []
try:
start_time = time.time() start_time = time.time()
try:
logging.info('Starting the analysis') logging.info('Starting the analysis')
if not os.path.isdir(self.infer_args.infer_out): if not os.path.isdir(self.infer_args.infer_out):
@ -478,12 +484,16 @@ class Wrapper:
buck_cmd = self.buck_cmd + javac_config buck_cmd = self.buck_cmd + javac_config
subprocess.check_call(buck_cmd) subprocess.check_call(buck_cmd)
self.timer.stop('Buck finished') self.timer.stop('Buck finished')
self.timer.start('Collecting results ...') self._collect_results(start_time)
collect_results(self.infer_args, start_time)
self.timer.stop('Done')
return os.EX_OK return os.EX_OK
except KeyboardInterrupt as e: except KeyboardInterrupt as e:
self.timer.stop('Exiting') self.timer.stop('Exiting')
sys.exit(0) 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: finally:
cleanup(temp_files) cleanup(temp_files)

Loading…
Cancel
Save