Skip to content

Commit

Permalink
[lit] Include total elapsed time in xunit output
Browse files Browse the repository at this point in the history
The time= attribute can also be used for the testsuites tag. While this
attribute appears to be ignored by Jenkins (https://github.com/jenkinsci/junit-plugin/blob/bab34bcc96154a494f8c371953efe06d45813f67/src/main/java/hudson/tasks/junit/SuiteResult.java#L202),
it is still useful if you manually inspect the xml file.

Reviewed By: yln

Differential Revision: https://reviews.llvm.org/D84230
  • Loading branch information
arichardson committed Jul 23, 2020
1 parent 9020d28 commit 722e5d6
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
3 changes: 1 addition & 2 deletions llvm/utils/lit/lit/reports.py
Expand Up @@ -74,14 +74,13 @@ def __init__(self, output_file):
self.skipped_codes = {lit.Test.EXCLUDED,
lit.Test.SKIPPED, lit.Test.UNSUPPORTED}

# TODO(yln): elapsed unused, put it somewhere?
def write_results(self, tests, elapsed):
tests.sort(key=by_suite_and_test_path)
tests_by_suite = itertools.groupby(tests, lambda t: t.suite)

with open(self.output_file, 'w') as file:
file.write('<?xml version="1.0" encoding="UTF-8"?>\n')
file.write('<testsuites>\n')
file.write('<testsuites time="{time:.2f}">\n'.format(time=elapsed))
for suite, test_iter in tests_by_suite:
self._write_testsuite(file, suite, list(test_iter))
file.write('</testsuites>\n')
Expand Down
2 changes: 1 addition & 1 deletion llvm/utils/lit/tests/shtest-format.py
Expand Up @@ -86,7 +86,7 @@


# XUNIT: <?xml version="1.0" encoding="UTF-8"?>
# XUNIT-NEXT: <testsuites>
# XUNIT-NEXT: <testsuites time="{{[0-9.]+}}">
# XUNIT-NEXT: <testsuite name="shtest-format" tests="21" failures="7" skipped="4">

# XUNIT: <testcase classname="shtest-format.external_shell" name="fail.txt" time="{{[0-9]+\.[0-9]+}}">
Expand Down
2 changes: 1 addition & 1 deletion llvm/utils/lit/tests/xunit-output.py
Expand Up @@ -8,7 +8,7 @@
# RUN: FileCheck < %t.xunit.xml %s

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

0 comments on commit 722e5d6

Please sign in to comment.