fix stuff that was accidentally broken

Reviewed By: martinoluca

Differential Revision: D2647203

fb-gh-sync-id: b1d3b78
master
Jules Villard 9 years ago committed by facebook-github-bot-1
parent 0490e739b0
commit d545da14c1

@ -6,11 +6,12 @@
# of patent rights can be found in the PATENTS file in the same directory.
import argparse
import json
import logging
import os
import subprocess
import traceback
import util
import logging
from inferlib import utils
@ -93,7 +94,8 @@ class BuckAnalyzer:
)
args = [
'--config',
'infer.infer_bin={bin}'.format(bin=utils.get_infer_bin()),
'infer.infer_bin={bin}'
.format(bin=utils.BIN_DIRECTORY),
'--config',
'infer.clang_compiler={clang}'.format(clang=clang_path),
'--config',
@ -134,11 +136,11 @@ class BuckAnalyzer:
if not ret == os.EX_OK:
return ret
result_files = self._get_analysis_result_files()
merged_results_path = \
os.path.join(self.args.infer_out, utils.JSON_REPORT_FILENAME)
utils.merge_json_reports(
result_files,
merged_results_path)
all_results = utils.merge_json_arrays_from_files(result_files)
merged_results_path = os.path.join(self.args.infer_out,
utils.JSON_REPORT_FILENAME)
with open(merged_results_path, 'w') as file_out:
json.dump(all_results, file_out, indent=2)
# TODO: adapt issues.print_errors to support json and print on screen
print('Results saved in {results_path}'.format(
results_path=merged_results_path))

@ -95,7 +95,7 @@ def clean_json(args, json_report):
cmp=_compare_json_rows)
temporary_file = tempfile.mktemp()
with open(temporary_file, 'w') as file_out:
json.dump(collected_rows, file_out)
json.dump(collected_rows, file_out, indent=2)
file_out.flush()
shutil.move(temporary_file, json_report)

@ -201,9 +201,13 @@ def run_command(cmd, debug_mode, infer_out, message, env=os.environ):
raise e
def print_exit(s):
print(s)
exit(os.EX_OK)
def merge_json_arrays_from_files(report_paths):
# TODO: use streams instead of loading the entire json in memory
json_data = []
for json_path in report_paths:
with codecs.open(json_path, 'r', encoding=config.LOCALE) as fd:
json_data = json_data + json.loads(fd.read())
return json_data
def infer_version():

Loading…
Cancel
Save