Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
14 changes: 11 additions & 3 deletions llvm/utils/lit/lit/reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

name = suite.config.name.replace(".", "-")
file.write(
f'<testsuite name={quo(name)} tests="{len(tests)}" failures="{failures}" skipped="{skipped}">\n'
f'<testsuite name={quo(name)} tests="{len(tests)}" failures="{failures}" skipped="{skipped}" time="{time:.2f}">\n'
)
for test in tests:
self._write_test(file, test, name)
Expand Down
2 changes: 1 addition & 1 deletion llvm/utils/lit/tests/shtest-format.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@

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

# XUNIT: <testcase classname="shtest-format.external_shell" name="fail.txt" time="{{[0-9]+\.[0-9]+}}">
# XUNIT-NEXT: <failure{{[ ]*}}>
Expand Down
2 changes: 1 addition & 1 deletion llvm/utils/lit/tests/xunit-output.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

# 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">
# 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>
Expand Down
Loading