[lit] Small refinements for xunit report output

This commit is contained in:
Julian Lettner 2020-05-01 15:20:18 -07:00
parent 7ffb5bc2a2
commit 201e73cbbb
3 changed files with 12 additions and 12 deletions

View File

@ -76,7 +76,7 @@ class XunitReport(object):
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('<?xml version="1.0" encoding="UTF-8"?>\n')
file.write('<testsuites>\n')
for suite, test_iter in tests_by_suite:
self._write_testsuite(file, suite, list(test_iter))
@ -100,7 +100,7 @@ class XunitReport(object):
file.write(f'<testcase classname={quo(class_name)} name={quo(name)} time="{time:.2f}"')
if test.isFailure():
file.write('>\n\t<failure ><![CDATA[')
file.write('>\n <failure><![CDATA[')
# In the unlikely case that the output contains the CDATA
# terminator we wrap it by creating a new CDATA block.
output = test.result.output.replace(']]>', ']]]]><![CDATA[>')
@ -110,7 +110,7 @@ class XunitReport(object):
file.write(']]></failure>\n</testcase>\n')
elif test.result.code in self.skipped_codes:
reason = self._get_skip_reason(test)
file.write(f'>\n\t<skipped message={quo(reason)} />\n</testcase>\n\n')
file.write(f'>\n <skipped message={quo(reason)}/>\n</testcase>\n')
else:
file.write('/>\n')
@ -124,5 +124,5 @@ class XunitReport(object):
assert code == lit.Test.UNSUPPORTED
features = test.getMissingRequiredFeatures()
if features:
return 'Skipping because of: ' + ', '.join(features)
return 'Skipping because of configuration.'
return 'Missing required feature(s): ' + ', '.join(features)
return 'Skipping because of configuration'

View File

@ -86,7 +86,7 @@
# CHECK: Unexpected Passes : 1
# XUNIT: <?xml version="1.0" encoding="UTF-8" ?>
# XUNIT: <?xml version="1.0" encoding="UTF-8"?>
# XUNIT-NEXT: <testsuites>
# XUNIT-NEXT: <testsuite name="shtest-format" tests="22" failures="7" skipped="4">
@ -118,7 +118,7 @@
# XUNIT: <testcase classname="shtest-format.shtest-format" name="pass.txt" time="{{[0-9]+\.[0-9]+}}"/>
# XUNIT: <testcase classname="shtest-format.shtest-format" name="requires-missing.txt" time="{{[0-9]+\.[0-9]+}}">
# XUNIT-NEXT:<skipped message="Skipping because of: a-missing-feature" />
# XUNIT-NEXT:<skipped message="Missing required feature(s): a-missing-feature"/>
# XUNIT: <testcase classname="shtest-format.shtest-format" name="requires-present.txt" time="{{[0-9]+\.[0-9]+}}"/>
@ -129,12 +129,12 @@
# XUNIT: <testcase classname="shtest-format.shtest-format" name="requires-triple.txt" time="{{[0-9]+\.[0-9]+}}">
# XUNIT-NEXT:<skipped message="Skipping because of: x86_64" />
# XUNIT-NEXT:<skipped message="Missing required feature(s): x86_64"/>
# XUNIT: <testcase classname="shtest-format.shtest-format" name="unsupported-expr-false.txt" time="{{[0-9]+\.[0-9]+}}"/>
# XUNIT: <testcase classname="shtest-format.shtest-format" name="unsupported-expr-true.txt" time="{{[0-9]+\.[0-9]+}}">
# XUNIT-NEXT:<skipped message="Skipping because of configuration." />
# XUNIT-NEXT:<skipped message="Skipping because of configuration"/>
# XUNIT: <testcase classname="shtest-format.shtest-format" name="unsupported-star.txt" time="{{[0-9]+\.[0-9]+}}">
# XUNIT-NEXT: <failure{{[ ]*}}>
@ -142,7 +142,7 @@
# XUNIT-NEXT: </testcase>
# XUNIT: <testcase classname="shtest-format.unsupported_dir" name="some-test.txt" time="{{[0-9]+\.[0-9]+}}">
# XUNIT-NEXT:<skipped message="Skipping because of configuration." />
# XUNIT-NEXT:<skipped message="Skipping because of configuration"/>
# XUNIT: <testcase classname="shtest-format.shtest-format" name="xfail-expr-false.txt" time="{{[0-9]+\.[0-9]+}}"/>

View File

@ -7,10 +7,10 @@
# RUN: sh -c 'if command -v xmllint 2>/dev/null; then xmllint --noout %t.xunit.xml; fi'
# RUN: FileCheck < %t.xunit.xml %s
# CHECK: <?xml version="1.0" encoding="UTF-8" ?>
# CHECK: <?xml version="1.0" encoding="UTF-8"?>
# CHECK: <testsuites>
# CHECK: <testsuite name="test-data" tests="1" failures="1" skipped="0">
# CHECK: <testcase classname="test-data.test-data" name="bad&amp;name.ini" time="{{[0-1]}}.{{[0-9]+}}">
# CHECK-NEXT: <failure ><![CDATA[& < > ]]]]><![CDATA[> &"]]></failure>
# CHECK-NEXT: <failure><![CDATA[& < > ]]]]><![CDATA[> &"]]></failure>
# CHECK: </testsuite>
# CHECK: </testsuites>