[LIT] replace output escapes wit a cdata block
authorChris Matthews <cmatthews5@apple.com>
Fri, 11 May 2018 18:38:02 +0000 (18:38 +0000)
committerChris Matthews <cmatthews5@apple.com>
Fri, 11 May 2018 18:38:02 +0000 (18:38 +0000)
CDATA blocks don't need to have XML stuff escaped. Makes sense to wrap
output in them instead of escaping.

llvm-svn: 332116

llvm/utils/lit/lit/Test.py
llvm/utils/lit/tests/xunit-output.py

index 1a454929dd12724b932744aad844b8ae20d1635a..c6ab5056b4d3a0b098b8daf4ef6e239e99422644 100644 (file)
@@ -376,9 +376,9 @@ class Test:
         testcase_xml = testcase_template.format(class_name=class_name, test_name=test_name, time=elapsed_time)
         fil.write(testcase_xml)
         if self.result.code.isFailure:
-            fil.write(u">\n\t<failure >\n")
-            fil.write(escape(self.result.output))
-            fil.write(u"\n\t</failure>\n</testcase>")
+            fil.write(u">\n\t<failure ><![CDATA[")
+            fil.write(self.result.output)
+            fil.write(u"]]></failure>\n</testcase>")
         elif self.result.code == UNSUPPORTED:
             fil.write(u">\n\t<skipped />\n</testcase>\n")
         else:
index 965a01c095f96182474183cb2dc1972f94df0d72..352f67e0823b0b041e07ca4c9562a23857071434 100644 (file)
@@ -6,8 +6,6 @@
 # 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 >
-# CHECK-NEXT:&amp; &lt; &gt; "
-# CHECK-NEXT:</failure>
+# CHECK-NEXT: <failure ><![CDATA[& < > "]]></failure>
 # CHECK: </testsuite>
 # CHECK: </testsuites>