mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 11:13:28 +01:00
Use quoteattr to ensure we make well formed attributes
We were making malformed XML on tests with ' in the name. Switch to using saxutils to set all of our attributes, so it can handle quotes etc correctly. llvm-svn: 333249
This commit is contained in:
parent
2f653c41c6
commit
0b61b91c62
@ -1,5 +1,5 @@
|
||||
import os
|
||||
from xml.sax.saxutils import escape
|
||||
from xml.sax.saxutils import quoteattr
|
||||
from json import JSONEncoder
|
||||
|
||||
from lit.BooleanExpression import BooleanExpression
|
||||
@ -362,7 +362,7 @@ class Test:
|
||||
|
||||
def writeJUnitXML(self, fil):
|
||||
"""Write the test's report xml representation to a file handle."""
|
||||
test_name = escape(self.path_in_suite[-1])
|
||||
test_name = quoteattr(self.path_in_suite[-1])
|
||||
test_path = self.path_in_suite[:-1]
|
||||
safe_test_path = [x.replace(".","_") for x in test_path]
|
||||
safe_name = self.suite.name.replace(".","-")
|
||||
@ -371,7 +371,8 @@ class Test:
|
||||
class_name = safe_name + "." + "/".join(safe_test_path)
|
||||
else:
|
||||
class_name = safe_name + "." + safe_name
|
||||
testcase_template = "<testcase classname='{class_name}' name='{test_name}' time='{time:.2f}'"
|
||||
class_name = quoteattr(class_name)
|
||||
testcase_template = '<testcase classname={class_name} name={test_name} time="{time:.2f}"'
|
||||
elapsed_time = self.result.elapsed if self.result.elapsed is not None else 0.0
|
||||
testcase_xml = testcase_template.format(class_name=class_name, test_name=test_name, time=elapsed_time)
|
||||
fil.write(testcase_xml)
|
||||
@ -388,10 +389,10 @@ class Test:
|
||||
elif self.result.code == UNSUPPORTED:
|
||||
unsupported_features = self.getMissingRequiredFeatures()
|
||||
if unsupported_features:
|
||||
skip_message = escape("Skipping because of: " + ", ".join(unsupported_features))
|
||||
skip_message = "Skipping because of: " + ", ".join(unsupported_features)
|
||||
else:
|
||||
skip_message = "Skipping because of configuration."
|
||||
|
||||
fil.write(">\n\t<skipped message=\"{}\" />\n</testcase>\n".format(skip_message))
|
||||
fil.write(">\n\t<skipped message={} />\n</testcase>\n".format(quoteattr(skip_message)))
|
||||
else:
|
||||
fil.write("/>")
|
||||
|
@ -16,6 +16,7 @@ import time
|
||||
import argparse
|
||||
import tempfile
|
||||
import shutil
|
||||
from xml.sax.saxutils import quoteattr
|
||||
|
||||
import lit.ProgressBar
|
||||
import lit.LitConfig
|
||||
@ -610,13 +611,13 @@ def main_with_tmp(builtinParameters):
|
||||
xunit_output_file.write("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n")
|
||||
xunit_output_file.write("<testsuites>\n")
|
||||
for suite_name, suite in by_suite.items():
|
||||
safe_suite_name = suite_name.replace(".", "-")
|
||||
xunit_output_file.write("<testsuite name='" + safe_suite_name + "'")
|
||||
xunit_output_file.write(" tests='" + str(suite['passes'] +
|
||||
suite['failures'] + suite['skipped']) + "'")
|
||||
xunit_output_file.write(" failures='" + str(suite['failures']) + "'")
|
||||
xunit_output_file.write(" skipped='" + str(suite['skipped']) +
|
||||
"'>\n")
|
||||
safe_suite_name = quoteattr(suite_name.replace(".", "-"))
|
||||
xunit_output_file.write("<testsuite name=" + safe_suite_name)
|
||||
xunit_output_file.write(" tests=\"" + str(suite['passes'] +
|
||||
suite['failures'] + suite['skipped']) + "\"")
|
||||
xunit_output_file.write(" failures=\"" + str(suite['failures']) + "\"")
|
||||
xunit_output_file.write(" skipped=\"" + str(suite['skipped']) +
|
||||
"\">\n")
|
||||
|
||||
for result_test in suite['tests']:
|
||||
result_test.writeJUnitXML(xunit_output_file)
|
||||
|
@ -4,78 +4,78 @@
|
||||
|
||||
# CHECK: <?xml version="1.0" encoding="UTF-8" ?>
|
||||
# CHECK-NEXT: <testsuites>
|
||||
# CHECK-NEXT: <testsuite name='shtest-format' tests='23' failures='7' skipped='5'>
|
||||
# CHECK-NEXT: <testsuite name="shtest-format" tests="23" failures="7" skipped="5">
|
||||
|
||||
# CHECK: <testcase classname='shtest-format.shtest-format' name='argv0.txt' time='{{[0-9]+\.[0-9]+}}'/>
|
||||
# CHECK: <testcase classname="shtest-format.shtest-format" name="argv0.txt" time="{{[0-9]+\.[0-9]+}}"/>
|
||||
|
||||
# CHECK: <testcase classname='shtest-format.external_shell' name='fail.txt' time='{{[0-9]+\.[0-9]+}}'>
|
||||
# CHECK: <testcase classname="shtest-format.external_shell" name="fail.txt" time="{{[0-9]+\.[0-9]+}}">
|
||||
# CHECK-NEXT: <failure{{[ ]*}}>
|
||||
# CHECK: </failure>
|
||||
# CHECK-NEXT: </testcase>
|
||||
|
||||
|
||||
# CHECK: <testcase classname='shtest-format.external_shell' name='fail_with_bad_encoding.txt' time='{{[0-9]+\.[0-9]+}}'>
|
||||
# CHECK: <testcase classname="shtest-format.external_shell" name="fail_with_bad_encoding.txt" time="{{[0-9]+\.[0-9]+}}">
|
||||
# CHECK-NEXT: <failure{{[ ]*}}>
|
||||
# CHECK: </failure>
|
||||
# CHECK-NEXT: </testcase>
|
||||
|
||||
# CHECK: <testcase classname='shtest-format.external_shell' name='pass.txt' time='{{[0-9]+\.[0-9]+}}'/>
|
||||
# CHECK: <testcase classname="shtest-format.external_shell" name="pass.txt" time="{{[0-9]+\.[0-9]+}}"/>
|
||||
|
||||
# CHECK: <testcase classname='shtest-format.shtest-format' name='fail.txt' time='{{[0-9]+\.[0-9]+}}'>
|
||||
# CHECK: <testcase classname="shtest-format.shtest-format" name="fail.txt" time="{{[0-9]+\.[0-9]+}}">
|
||||
# CHECK-NEXT: <failure{{[ ]*}}>
|
||||
# CHECK: </failure>
|
||||
# CHECK-NEXT: </testcase>
|
||||
|
||||
# CHECK: <testcase classname='shtest-format.shtest-format' name='no-test-line.txt' time='{{[0-9]+\.[0-9]+}}'>
|
||||
# CHECK: <testcase classname="shtest-format.shtest-format" name="no-test-line.txt" time="{{[0-9]+\.[0-9]+}}">
|
||||
# CHECK-NEXT: <failure{{[ ]*}}>
|
||||
# CHECK: </failure>
|
||||
# CHECK-NEXT: </testcase>
|
||||
|
||||
# CHECK: <testcase classname='shtest-format.shtest-format' name='pass.txt' time='{{[0-9]+\.[0-9]+}}'/>
|
||||
# CHECK: <testcase classname="shtest-format.shtest-format" name="pass.txt" time="{{[0-9]+\.[0-9]+}}"/>
|
||||
|
||||
# CHECK: <testcase classname='shtest-format.shtest-format' name='requires-any-missing.txt' time='{{[0-9]+\.[0-9]+}}'>
|
||||
# CHECK: <testcase classname="shtest-format.shtest-format" name="requires-any-missing.txt" time="{{[0-9]+\.[0-9]+}}">
|
||||
# CHECK-NEXT:<skipped message="Skipping because of: a-missing-feature || a-missing-feature-2" />
|
||||
|
||||
# CHECK: <testcase classname='shtest-format.shtest-format' name='requires-any-present.txt' time='{{[0-9]+\.[0-9]+}}'/>
|
||||
# CHECK: <testcase classname="shtest-format.shtest-format" name="requires-any-present.txt" time="{{[0-9]+\.[0-9]+}}"/>
|
||||
|
||||
# CHECK: <testcase classname='shtest-format.shtest-format' name='requires-missing.txt' time='{{[0-9]+\.[0-9]+}}'>
|
||||
# CHECK: <testcase classname="shtest-format.shtest-format" name="requires-missing.txt" time="{{[0-9]+\.[0-9]+}}">
|
||||
# CHECK-NEXT:<skipped message="Skipping because of: a-missing-feature" />
|
||||
|
||||
# CHECK: <testcase classname='shtest-format.shtest-format' name='requires-present.txt' time='{{[0-9]+\.[0-9]+}}'/>
|
||||
# CHECK: <testcase classname="shtest-format.shtest-format" name="requires-present.txt" time="{{[0-9]+\.[0-9]+}}"/>
|
||||
|
||||
# CHECK: <testcase classname='shtest-format.shtest-format' name='requires-star.txt' time='{{[0-9]+\.[0-9]+}}'>
|
||||
# CHECK: <testcase classname="shtest-format.shtest-format" name="requires-star.txt" time="{{[0-9]+\.[0-9]+}}">
|
||||
# CHECK-NEXT: <failure{{[ ]*}}>
|
||||
# CHECK: </failure>
|
||||
# CHECK-NEXT: </testcase>
|
||||
|
||||
|
||||
# CHECK: <testcase classname='shtest-format.shtest-format' name='requires-triple.txt' time='{{[0-9]+\.[0-9]+}}'>
|
||||
# CHECK: <testcase classname="shtest-format.shtest-format" name="requires-triple.txt" time="{{[0-9]+\.[0-9]+}}">
|
||||
# CHECK-NEXT:<skipped message="Skipping because of: x86_64" />
|
||||
|
||||
# CHECK: <testcase classname='shtest-format.shtest-format' name='unsupported-expr-false.txt' time='{{[0-9]+\.[0-9]+}}'/>
|
||||
# CHECK: <testcase classname="shtest-format.shtest-format" name="unsupported-expr-false.txt" time="{{[0-9]+\.[0-9]+}}"/>
|
||||
|
||||
# CHECK: <testcase classname='shtest-format.shtest-format' name='unsupported-expr-true.txt' time='{{[0-9]+\.[0-9]+}}'>
|
||||
# CHECK: <testcase classname="shtest-format.shtest-format" name="unsupported-expr-true.txt" time="{{[0-9]+\.[0-9]+}}">
|
||||
# CHECK-NEXT:<skipped message="Skipping because of configuration." />
|
||||
|
||||
# CHECK: <testcase classname='shtest-format.shtest-format' name='unsupported-star.txt' time='{{[0-9]+\.[0-9]+}}'>
|
||||
# CHECK: <testcase classname="shtest-format.shtest-format" name="unsupported-star.txt" time="{{[0-9]+\.[0-9]+}}">
|
||||
# CHECK-NEXT: <failure{{[ ]*}}>
|
||||
# CHECK: </failure>
|
||||
# CHECK-NEXT: </testcase>
|
||||
|
||||
# CHECK: <testcase classname='shtest-format.unsupported_dir' name='some-test.txt' time='{{[0-9]+\.[0-9]+}}'>
|
||||
# CHECK: <testcase classname="shtest-format.unsupported_dir" name="some-test.txt" time="{{[0-9]+\.[0-9]+}}">
|
||||
# CHECK-NEXT:<skipped message="Skipping because of configuration." />
|
||||
|
||||
# CHECK: <testcase classname='shtest-format.shtest-format' name='xfail-expr-false.txt' time='{{[0-9]+\.[0-9]+}}'/>
|
||||
# CHECK: <testcase classname="shtest-format.shtest-format" name="xfail-expr-false.txt" time="{{[0-9]+\.[0-9]+}}"/>
|
||||
|
||||
# CHECK: <testcase classname='shtest-format.shtest-format' name='xfail-expr-true.txt' time='{{[0-9]+\.[0-9]+}}'/>
|
||||
# CHECK: <testcase classname="shtest-format.shtest-format" name="xfail-expr-true.txt" time="{{[0-9]+\.[0-9]+}}"/>
|
||||
|
||||
# CHECK: <testcase classname='shtest-format.shtest-format' name='xfail-feature.txt' time='{{[0-9]+\.[0-9]+}}'/>
|
||||
# CHECK: <testcase classname="shtest-format.shtest-format" name="xfail-feature.txt" time="{{[0-9]+\.[0-9]+}}"/>
|
||||
|
||||
# CHECK: <testcase classname='shtest-format.shtest-format' name='xfail-target.txt' time='{{[0-9]+\.[0-9]+}}'/>
|
||||
# CHECK: <testcase classname="shtest-format.shtest-format" name="xfail-target.txt" time="{{[0-9]+\.[0-9]+}}"/>
|
||||
|
||||
# CHECK: <testcase classname='shtest-format.shtest-format' name='xfail.txt' time='{{[0-9]+\.[0-9]+}}'/>
|
||||
# CHECK: <testcase classname="shtest-format.shtest-format" name="xfail.txt" time="{{[0-9]+\.[0-9]+}}"/>
|
||||
|
||||
# CHECK: <testcase classname='shtest-format.shtest-format' name='xpass.txt' time='{{[0-9]+\.[0-9]+}}'>
|
||||
# CHECK: <testcase classname="shtest-format.shtest-format" name="xpass.txt" time="{{[0-9]+\.[0-9]+}}">
|
||||
# CHECK-NEXT: <failure{{[ ]*}}>
|
||||
# CHECK: </failure>
|
||||
# CHECK-NEXT: </testcase>
|
||||
|
@ -9,8 +9,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&name.ini' time='{{[0-1]}}.{{[0-9]+}}'>
|
||||
# CHECK: <testsuite name="test-data" tests="1" failures="1" skipped="0">
|
||||
# CHECK: <testcase classname="test-data.test-data" name="bad&name.ini" time="{{[0-1]}}.{{[0-9]+}}">
|
||||
# CHECK-NEXT: <failure ><![CDATA[& < > ]]]]><![CDATA[> &"]]></failure>
|
||||
# CHECK: </testsuite>
|
||||
# CHECK: </testsuites>
|
||||
|
Loading…
Reference in New Issue
Block a user