diff --git a/llvm/docs/CommandGuide/lit.rst b/llvm/docs/CommandGuide/lit.rst index af8a1a08be535..8c0e275e1f8ca 100644 --- a/llvm/docs/CommandGuide/lit.rst +++ b/llvm/docs/CommandGuide/lit.rst @@ -191,6 +191,10 @@ EXECUTION OPTIONS Write XUnit-compatible XML test reports to the specified file. +.. option:: --report-failures-only + + Only include unresolved, timed out, failed and unexpectedly passed tests in the report. + .. option:: --resultdb-output RESULTDB_OUTPUT Write LuCI ResultDB compatible JSON to the specified file. diff --git a/llvm/utils/lit/lit/cl_arguments.py b/llvm/utils/lit/lit/cl_arguments.py index a401c9a09e081..1d776e0216a1e 100644 --- a/llvm/utils/lit/lit/cl_arguments.py +++ b/llvm/utils/lit/lit/cl_arguments.py @@ -165,6 +165,12 @@ def parse_args(): type=lit.reports.XunitReport, help="Write XUnit-compatible XML test reports to the specified file", ) + execution_group.add_argument( + "--report-failures-only", + help="Only include unresolved, timed out, failed" + " and unexpectedly passed tests in the report", + action="store_true", + ) execution_group.add_argument( "--resultdb-output", type=lit.reports.ResultDBReport, diff --git a/llvm/utils/lit/lit/main.py b/llvm/utils/lit/lit/main.py index 24ba804f0c363..ba80330d22400 100755 --- a/llvm/utils/lit/lit/main.py +++ b/llvm/utils/lit/lit/main.py @@ -137,6 +137,10 @@ def main(builtin_params={}): print_results(discovered_tests, elapsed, opts) tests_for_report = selected_tests if opts.shard else discovered_tests + if opts.report_failures_only: + # Only report tests that failed. + tests_for_report = [t for t in tests_for_report if t.isFailure()] + for report in opts.reports: report.write_results(tests_for_report, elapsed) diff --git a/llvm/utils/lit/tests/xunit-output-report-failures-only.py b/llvm/utils/lit/tests/xunit-output-report-failures-only.py new file mode 100644 index 0000000000000..e15fd6a009f99 --- /dev/null +++ b/llvm/utils/lit/tests/xunit-output-report-failures-only.py @@ -0,0 +1,12 @@ +## Check xunit output. +# RUN: not %{lit} --report-failures-only --xunit-xml-output %t.xunit.xml %{inputs}/xunit-output +# RUN: FileCheck --input-file=%t.xunit.xml %s + +# CHECK: +# CHECK-NEXT: +# CHECK-NEXT: +# CHECK-NEXT: +# CHECK-NEXT: ]]]]> &"]]> +# CHECK-NEXT: +# CHECK-NEXT: +# CHECK-NEXT: