Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions llvm/utils/lit/lit/cl_arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -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="When writing a 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,
Expand Down
4 changes: 4 additions & 0 deletions llvm/utils/lit/lit/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
6 changes: 2 additions & 4 deletions llvm/utils/lit/lit/reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ def __init__(self, output_file):
self.output_file = output_file
# Set by the option parser later.
self.use_unique_output_file_name = False
self.skipped_codes = {lit.Test.EXCLUDED,
lit.Test.SKIPPED, lit.Test.UNSUPPORTED}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whilst there's nothing fundamentally wrong with this, it looks like it's unrelated to the focus of the PR, so should be split into its own one, if you want to make the change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This made it's way over from patch #1 (https://reviews.llvm.org/D143516). However, since it's not required for my changes, I will split it into another PR as you are suggesting.


def write_results(self, tests, elapsed):
if self.use_unique_output_file_name:
Expand Down Expand Up @@ -114,8 +116,6 @@ def remove_invalid_xml_chars(s):


class XunitReport(Report):
skipped_codes = {lit.Test.EXCLUDED, lit.Test.SKIPPED, lit.Test.UNSUPPORTED}

def _write_results_to_file(self, tests, elapsed, file):
tests.sort(key=by_suite_and_test_path)
tests_by_suite = itertools.groupby(tests, lambda t: t.suite)
Expand Down Expand Up @@ -273,8 +273,6 @@ def _write_results_to_file(self, tests, elapsed, file):


class TimeTraceReport(Report):
skipped_codes = {lit.Test.EXCLUDED, lit.Test.SKIPPED, lit.Test.UNSUPPORTED}

def _write_results_to_file(self, tests, elapsed, file):
# Find when first test started so we can make start times relative.
first_start_time = min([t.result.start for t in tests])
Expand Down
17 changes: 17 additions & 0 deletions llvm/utils/lit/tests/xunit-output-report-failures-only.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# UNSUPPORTED: system-windows

# Check xunit output
# RUN: rm -rf %t.xunit.xml
# RUN: not %{lit} --report-failures-only --xunit-xml-output %t.xunit.xml %{inputs}/xunit-output
# If xmllint is installed verify that the generated xml is well-formed
# RUN: sh -c 'if command -v xmllint 2>/dev/null; then xmllint --noout %t.xunit.xml; fi'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels unnecessary, and it's forcing an UNSUPPORTED: system-windows line (actually, I suspect the requirement is on the shell not on non-Windows, but that's an aside - it would be better to not have the requirement at all). You're checking the contents of the file immediately below, so as long as your contents check is valid, you'll know that the XML must be valid.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have removed the xmllint check and the forced UNSUPPORTED: system-windows line. I've also removed the rm -rf line as it's not really needed because the previous file will get overwritten and I don't think it's supported in windows shell either.

# RUN: FileCheck < %t.xunit.xml %s
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The canonical way of passing an input file into FileCheck is to use --input-file.


# CHECK: <?xml version="1.0" encoding="UTF-8"?>
# CHECK-NEXT: <testsuites time="{{[0-9.]+}}">
# CHECK-NEXT: <testsuite name="test-data" tests="5" failures="1" skipped="3" time="{{[0-9.]+}}">
# CHECK-NEXT: <testcase classname="test-data.test-data" name="bad&amp;name.ini" time="{{[0-1]\.[0-9]+}}">
# CHECK-NEXT: <failure><![CDATA[& < > ]]]]><![CDATA[> &"]]></failure>
# CHECK-NEXT: </testcase>
# CHECK-NEXT: </testsuite>
# CHECK-NEXT: </testsuites>
Loading