diff options
Diffstat (limited to 'buildscripts/combine_reports.py')
-rwxr-xr-x | buildscripts/combine_reports.py | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/buildscripts/combine_reports.py b/buildscripts/combine_reports.py index e59cc29f172..45fc0bcf38b 100755 --- a/buildscripts/combine_reports.py +++ b/buildscripts/combine_reports.py @@ -1,7 +1,5 @@ #!/usr/bin/env python -""" -Combines JSON report files used in Evergreen -""" +"""Combine JSON report files used in Evergreen.""" from __future__ import absolute_import from __future__ import print_function @@ -16,20 +14,24 @@ from optparse import OptionParser if __name__ == "__main__" and __package__ is None: sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) -from buildscripts.resmokelib.testing import report -from buildscripts.resmokelib import utils +from buildscripts.resmokelib.testing import report # pylint: disable=wrong-import-position +from buildscripts.resmokelib import utils # pylint: disable=wrong-import-position def read_json_file(json_file): + """Read JSON file.""" with open(json_file) as json_data: return json.load(json_data) def report_exit(combined_test_report): - """The exit code of this script is based on the following: + """Return report exit code. + + The exit code of this script is based on the following: 0: All tests have status "pass", or only non-dynamic tests have status "silentfail". 31: At least one test has status "fail" or "timeout". - Note: A test can be considered dynamic if its name contains a ":" character.""" + Note: A test can be considered dynamic if its name contains a ":" character. + """ ret = 0 for test in combined_test_report.test_infos: @@ -39,9 +41,7 @@ def report_exit(combined_test_report): def check_error(input_count, output_count): - """ - Error if both input and output exist, or if neither exist. - """ + """Raise error if both input and output exist, or if neither exist.""" if (not input_count) and (not output_count): raise ValueError("None of the input file(s) or output file exists") @@ -50,6 +50,7 @@ def check_error(input_count, output_count): def main(): + """Execute Main program.""" usage = "usage: %prog [options] report1.json report2.json ..." parser = OptionParser(description=__doc__, usage=usage) parser.add_option("-o", "--output-file", dest="outfile", default="-", @@ -73,9 +74,9 @@ def main(): try: report_file_json = read_json_file(report_file) test_reports.append(report.TestReport.from_dict(report_file_json)) - except IOError as e: + except IOError as err: # errno.ENOENT is the error code for "No such file or directory". - if e.errno == errno.ENOENT: + if err.errno == errno.ENOENT: report_files_count -= 1 continue raise |