[llvm] r331942 - [LIT] Handle xml characters in test names
Chris Matthews via llvm-commits
llvm-commits at lists.llvm.org
Wed May 9 16:48:32 PDT 2018
Author: cmatthews
Date: Wed May 9 16:48:32 2018
New Revision: 331942
URL: http://llvm.org/viewvc/llvm-project?rev=331942&view=rev
Log:
[LIT] Handle xml characters in test names
Lit creates malformed xml when the test case has an & in the name.
Escape those correctly.
This also adds a test case which I will add other nasty encoding issues to in some followup commits.
Modified:
llvm/trunk/utils/lit/lit/Test.py
llvm/trunk/utils/lit/tests/test-output.py
llvm/trunk/utils/lit/tests/xunit-output.py
Modified: llvm/trunk/utils/lit/lit/Test.py
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/lit/Test.py?rev=331942&r1=331941&r2=331942&view=diff
==============================================================================
--- llvm/trunk/utils/lit/lit/Test.py (original)
+++ llvm/trunk/utils/lit/lit/Test.py Wed May 9 16:48:32 2018
@@ -361,7 +361,7 @@ class Test:
return self.suite.config.is_early
def getJUnitXML(self):
- test_name = self.path_in_suite[-1]
+ test_name = escape(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(".","-")
Modified: llvm/trunk/utils/lit/tests/test-output.py
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/tests/test-output.py?rev=331942&r1=331941&r2=331942&view=diff
==============================================================================
--- llvm/trunk/utils/lit/tests/test-output.py (original)
+++ llvm/trunk/utils/lit/tests/test-output.py Wed May 9 16:48:32 2018
@@ -12,8 +12,19 @@
# CHECK-NEXT: "value0": 1,
# CHECK-NEXT: "value1": 2.3456
# CHECK-NEXT: }
+# CHECK-NEXT: "name": "test-data :: bad&name.ini",
+# CHECK-NEXT: "output": "& < > \""
+# CHECK-NEXT: },
+# CHECK-NEXT: {
+# CHECK-NEXT: "code": "PASS",
+# CHECK-NEXT: "elapsed": {{[0-9.]+}},
+# CHECK-NEXT: "metrics": {
+# CHECK-NEXT: "value0": 1,
+# CHECK-NEXT: "value1": 2.3456
+# CHECK-NEXT: }
# CHECK-NEXT: "name": "test-data :: metrics.ini",
# CHECK-NEXT: "output": "Test passed."
# CHECK-NEXT: }
+
# CHECK-NEXT: ]
# CHECK-NEXT: }
Modified: llvm/trunk/utils/lit/tests/xunit-output.py
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/tests/xunit-output.py?rev=331942&r1=331941&r2=331942&view=diff
==============================================================================
--- llvm/trunk/utils/lit/tests/xunit-output.py (original)
+++ llvm/trunk/utils/lit/tests/xunit-output.py Wed May 9 16:48:32 2018
@@ -4,7 +4,8 @@
# CHECK: <?xml version="1.0" encoding="UTF-8" ?>
# CHECK: <testsuites>
-# CHECK: <testsuite name='test-data' tests='1' failures='0'>
+# CHECK: <testsuite name='test-data' tests='2' failures='0'>
+# CHECK: <testcase classname='test-data.test-data' name='bad&name.ini' time='{{[0-1]}}.{{[0-9]+}}'/>
# CHECK: <testcase classname='test-data.test-data' name='metrics.ini' time='{{[0-1]}}.{{[0-9]+}}'/>
# CHECK: </testsuite>
# CHECK: </testsuites>
More information about the llvm-commits
mailing list