[PATCH] D46886: Escape ]]> in xunit xml output
Alexander Richardson via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue May 15 09:02:54 PDT 2018
arichardson created this revision.
arichardson added a reviewer: cmatthews.
Herald added subscribers: llvm-commits, delcypher.
This sequence ends the CDATA block so any characters after that are no
longer escaped. This can be fixed by replacing "]]>" with "]]]]><![CDATA[>".
Repository:
rL LLVM
https://reviews.llvm.org/D46886
Files:
utils/lit/lit/Test.py
utils/lit/tests/Inputs/xunit-output/bad&name.ini
utils/lit/tests/xunit-output.py
Index: utils/lit/tests/xunit-output.py
===================================================================
--- utils/lit/tests/xunit-output.py
+++ utils/lit/tests/xunit-output.py
@@ -1,11 +1,13 @@
# Check xunit output
# RUN: %{lit} --xunit-xml-output %t.xunit.xml %{inputs}/xunit-output || true
+# If xmllint is installed verify that the generated xml is well-formed
+# 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: <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-NEXT: <failure ><![CDATA[& < > "]]></failure>
+# CHECK-NEXT: <failure ><![CDATA[& < > ]]]]><![CDATA[> &"]]></failure>
# CHECK: </testsuite>
# CHECK: </testsuites>
Index: utils/lit/tests/Inputs/xunit-output/bad&name.ini
===================================================================
--- utils/lit/tests/Inputs/xunit-output/bad&name.ini
+++ utils/lit/tests/Inputs/xunit-output/bad&name.ini
@@ -1,7 +1,7 @@
[global]
result_code = FAIL
-result_output = & < > "
+result_output = & < > ]]> &"
[results]
value0 = 1
-value1 = 2.3456
\ No newline at end of file
+value1 = 2.3456
Index: utils/lit/lit/Test.py
===================================================================
--- utils/lit/lit/Test.py
+++ utils/lit/lit/Test.py
@@ -381,7 +381,9 @@
encoded_output = self.result.output.encode("utf-8", 'ignore')
else:
encoded_output = self.result.output
- fil.write(encoded_output)
+ # In the unlikely case that the output contains the CDATA terminator
+ # we wrap it by creating a new CDATA block
+ fil.write(encoded_output.replace("]]>", "]]]]><![CDATA[>"))
fil.write("]]></failure>\n</testcase>")
elif self.result.code == UNSUPPORTED:
unsupported_features = self.getMissingRequiredFeatures()
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46886.146849.patch
Type: text/x-patch
Size: 2080 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180515/541be4f7/attachment.bin>
More information about the llvm-commits
mailing list