Skip to content

Commit 722e5d6

Browse files
committed
[lit] Include total elapsed time in xunit output
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
1 parent 9020d28 commit 722e5d6

File tree

3 files changed

+3
-4
lines changed

3 files changed

+3
-4
lines changed

llvm/utils/lit/lit/reports.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,13 @@ def __init__(self, output_file):
7474
self.skipped_codes = {lit.Test.EXCLUDED,
7575
lit.Test.SKIPPED, lit.Test.UNSUPPORTED}
7676

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

8281
with open(self.output_file, 'w') as file:
8382
file.write('<?xml version="1.0" encoding="UTF-8"?>\n')
84-
file.write('<testsuites>\n')
83+
file.write('<testsuites time="{time:.2f}">\n'.format(time=elapsed))
8584
for suite, test_iter in tests_by_suite:
8685
self._write_testsuite(file, suite, list(test_iter))
8786
file.write('</testsuites>\n')

llvm/utils/lit/tests/shtest-format.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686

8787

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

9292
# XUNIT: <testcase classname="shtest-format.external_shell" name="fail.txt" time="{{[0-9]+\.[0-9]+}}">

llvm/utils/lit/tests/xunit-output.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
# RUN: FileCheck < %t.xunit.xml %s
99

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

0 commit comments

Comments
 (0)