[llvm] [llvm][llvm-lit] Add total time for each testsuite in JUnit XML output (PR #112230)

Sergei Barannikov via llvm-commits llvm-commits at lists.llvm.org
Sun Oct 20 03:00:39 PDT 2024


================
@@ -105,12 +105,20 @@ def write_results(self, tests, elapsed):
             file.write("</testsuites>\n")
 
     def _write_testsuite(self, file, suite, tests):
-        skipped = sum(1 for t in tests if t.result.code in self.skipped_codes)
-        failures = sum(1 for t in tests if t.isFailure())
+        skipped = 0
+        failures = 0
+        time = 0.0
+
+        for t in tests:
+            if t.result.code in self.skipped_codes:
+                skipped += 1
+            if t.isFailure():
+                failures += 1
+            time += t.result.elapsed
----------------
s-barannikov wrote:

I get an error on this line when running `build/bin/llvm-lit -v --xunit-xml-output check-llvm.xml llvm/test`
```
Testing Time: 82.96s
Total Discovered Tests: 62173
  Excluded         :     5 (0.01%)
  Skipped          :   581 (0.93%)
  Unsupported      : 40415 (65.00%)
  Passed           : 21133 (33.99%)
  Expectedly Failed:    39 (0.06%)
  File "<...>/llvm/utils/lit/lit/reports.py", line 117, in _write_testsuite
    time += t.result.elapsed
TypeError: unsupported operand type(s) for +=: 'float' and 'NoneType'
```

I noticed that the function below refers to the variable as `test.result.elapsed or 0.0`. Should it be the same here?


https://github.com/llvm/llvm-project/pull/112230


More information about the llvm-commits mailing list