Index: llvm/utils/lit/lit/cl_arguments.py =================================================================== --- llvm/utils/lit/lit/cl_arguments.py +++ llvm/utils/lit/lit/cl_arguments.py @@ -118,6 +118,11 @@ execution_group.add_argument("--xunit-xml-output", type=lit.reports.XunitReport, help="Write XUnit-compatible XML test reports to the specified file") + execution_group.add_argument("--reduced-xunit-report", + dest="reducedXUnitReport", + help="When writing an XUNit test report, do not include results for " + "tests that completed successfully or were not run", + action="store_true") execution_group.add_argument("--resultdb-output", type=lit.reports.ResultDBReport, help="Write LuCI ResuldDB compatible JSON to the specified file") Index: llvm/utils/lit/lit/main.py =================================================================== --- llvm/utils/lit/lit/main.py +++ llvm/utils/lit/lit/main.py @@ -118,7 +118,7 @@ tests_for_report = selected_tests if opts.shard else discovered_tests for report in opts.reports: - report.write_results(tests_for_report, elapsed) + report.write_results(tests_for_report, elapsed, opts) if lit_config.numErrors: sys.stderr.write('\n%d error(s) in tests\n' % lit_config.numErrors) Index: llvm/utils/lit/lit/reports.py =================================================================== --- llvm/utils/lit/lit/reports.py +++ llvm/utils/lit/lit/reports.py @@ -19,14 +19,17 @@ self.output_file = output_file self.skipped_codes = {lit.Test.EXCLUDED, lit.Test.SKIPPED, lit.Test.UNSUPPORTED} + self.failed_codes = {lit.Test.UNRESOLVED, lit.Test.TIMEOUT, + lit.Test.FAIL, lit.Test.XPASS} @abc.abstractmethod - def write_results(self, tests, elapsed): + def write_results(self, tests, elapsed, opts): ... class JsonReport(_ReportBase): - def write_results(self, tests, elapsed): + def write_results(self, tests, elapsed, opts): + del opts unexecuted_codes = {lit.Test.EXCLUDED, lit.Test.SKIPPED} tests = [t for t in tests if t.result.code not in unexecuted_codes] # Construct the data we will write. @@ -93,7 +96,9 @@ class XunitReport(_ReportBase): - def write_results(self, tests, elapsed): + def write_results(self, tests, elapsed, opts): + + reduced_report = opts.reducedXUnitReport tests.sort(key=by_suite_and_test_path) tests_by_suite = itertools.groupby(tests, lambda t: t.suite) @@ -101,16 +106,18 @@ file.write('\n') file.write('\n'.format(time=elapsed)) for suite, test_iter in tests_by_suite: - self._write_testsuite(file, suite, list(test_iter)) + self._write_testsuite(file, suite, list(test_iter), reduced_report) file.write('\n') - def _write_testsuite(self, file, suite, tests): + def _write_testsuite(self, file, suite, tests, reduced_report): skipped = sum(1 for t in tests if t.result.code in self.skipped_codes) failures = sum(1 for t in tests if t.isFailure()) name = suite.config.name.replace('.', '-') file.write(f'\n') for test in tests: + if reduced_report and test.result.code not in self.failed_codes: + continue self._write_test(file, test, name) file.write('\n') @@ -195,7 +202,8 @@ class ResultDBReport(_ReportBase): - def write_results(self, tests, elapsed): + def write_results(self, tests, elapsed, opts): + del opts unexecuted_codes = {lit.Test.EXCLUDED, lit.Test.SKIPPED} tests = [t for t in tests if t.result.code not in unexecuted_codes] data = {} @@ -240,8 +248,8 @@ class TimeTraceReport(_ReportBase): - def write_results(self, tests, elapsed): - del elapsed + def write_results(self, tests, elapsed, opts): + del elapsed, opts # Find when first test started so we can make start times relative. first_start_time = min([t.result.start for t in tests])