[llvm] 722e5d6 - [lit] Include total elapsed time in xunit output

Alex Richardson via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 23 03:23:32 PDT 2020


Author: Alex Richardson
Date: 2020-07-23T11:19:18+01:00
New Revision: 722e5d6aaeb5ec0e75506de19e582302c65734cc

URL: https://github.com/llvm/llvm-project/commit/722e5d6aaeb5ec0e75506de19e582302c65734cc
DIFF: https://github.com/llvm/llvm-project/commit/722e5d6aaeb5ec0e75506de19e582302c65734cc.diff

LOG: [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

Added: 
    

Modified: 
    llvm/utils/lit/lit/reports.py
    llvm/utils/lit/tests/shtest-format.py
    llvm/utils/lit/tests/xunit-output.py

Removed: 
    


################################################################################
diff  --git a/llvm/utils/lit/lit/reports.py b/llvm/utils/lit/lit/reports.py
index c23b4c714090..9631d5fe3b35 100755
--- a/llvm/utils/lit/lit/reports.py
+++ b/llvm/utils/lit/lit/reports.py
@@ -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')

diff  --git a/llvm/utils/lit/tests/shtest-format.py b/llvm/utils/lit/tests/shtest-format.py
index 86742e39ac4b..aa74a2caa8a2 100644
--- a/llvm/utils/lit/tests/shtest-format.py
+++ b/llvm/utils/lit/tests/shtest-format.py
@@ -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]+}}">

diff  --git a/llvm/utils/lit/tests/xunit-output.py b/llvm/utils/lit/tests/xunit-output.py
index 32a35f82a943..81d8525f33b4 100644
--- a/llvm/utils/lit/tests/xunit-output.py
+++ b/llvm/utils/lit/tests/xunit-output.py
@@ -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&name.ini" time="{{[0-1]\.[0-9]+}}">
 # CHECK-NEXT:   <failure><![CDATA[& < > ]]]]><![CDATA[> &"]]></failure>


        


More information about the llvm-commits mailing list