Skip to content

Commit c63e83f

Browse files
rpatel321gregbedwelljh7370
authored
[lit] Add --report-failures-only option for lit test reports (#115439)
- Add option (--report-failures-only) to generate a reduced report for lit tests that only includes failing tests - This is a continuation of proposed patches by @gregbedwell here: - https://reviews.llvm.org/D143516 - https://reviews.llvm.org/D143519 --------- Co-authored-by: Greg Bedwell <[email protected]> Co-authored-by: James Henderson <[email protected]>
1 parent 7a1fdbb commit c63e83f

File tree

4 files changed

+26
-0
lines changed

4 files changed

+26
-0
lines changed

llvm/docs/CommandGuide/lit.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,10 @@ EXECUTION OPTIONS
191191

192192
Write XUnit-compatible XML test reports to the specified file.
193193

194+
.. option:: --report-failures-only
195+
196+
Only include unresolved, timed out, failed and unexpectedly passed tests in the report.
197+
194198
.. option:: --resultdb-output RESULTDB_OUTPUT
195199

196200
Write LuCI ResultDB compatible JSON to the specified file.

llvm/utils/lit/lit/cl_arguments.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,12 @@ def parse_args():
165165
type=lit.reports.XunitReport,
166166
help="Write XUnit-compatible XML test reports to the specified file",
167167
)
168+
execution_group.add_argument(
169+
"--report-failures-only",
170+
help="Only include unresolved, timed out, failed"
171+
" and unexpectedly passed tests in the report",
172+
action="store_true",
173+
)
168174
execution_group.add_argument(
169175
"--resultdb-output",
170176
type=lit.reports.ResultDBReport,

llvm/utils/lit/lit/main.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,10 @@ def main(builtin_params={}):
137137
print_results(discovered_tests, elapsed, opts)
138138

139139
tests_for_report = selected_tests if opts.shard else discovered_tests
140+
if opts.report_failures_only:
141+
# Only report tests that failed.
142+
tests_for_report = [t for t in tests_for_report if t.isFailure()]
143+
140144
for report in opts.reports:
141145
report.write_results(tests_for_report, elapsed)
142146

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
## Check xunit output.
2+
# RUN: not %{lit} --report-failures-only --xunit-xml-output %t.xunit.xml %{inputs}/xunit-output
3+
# RUN: FileCheck --input-file=%t.xunit.xml %s
4+
5+
# CHECK: <?xml version="1.0" encoding="UTF-8"?>
6+
# CHECK-NEXT: <testsuites time="{{[0-9.]+}}">
7+
# CHECK-NEXT: <testsuite name="test-data" tests="1" failures="1" skipped="0" time="{{[0-9.]+}}">
8+
# CHECK-NEXT: <testcase classname="test-data.test-data" name="bad&amp;name.ini" time="{{[0-1]\.[0-9]+}}">
9+
# CHECK-NEXT: <failure><![CDATA[& < > ]]]]><![CDATA[> &"]]></failure>
10+
# CHECK-NEXT: </testcase>
11+
# CHECK-NEXT: </testsuite>
12+
# CHECK-NEXT: </testsuites>

0 commit comments

Comments
 (0)