testsuite/junit: Properly escape strings
authorBen Gamari <ben@smart-cactus.org>
Mon, 31 Jul 2017 15:36:49 +0000 (11:36 -0400)
committerBen Gamari <ben@smart-cactus.org>
Fri, 18 Aug 2017 03:49:51 +0000 (23:49 -0400)
testsuite/driver/junit.py

index f9689de..4015c19 100644 (file)
@@ -1,5 +1,6 @@
 from datetime import datetime
 import xml.etree.ElementTree as ET
+from xml.sax.saxutils import escape
 
 def junit(t):
     testsuites = ET.Element('testsuites')
@@ -18,21 +19,21 @@ def junit(t):
                                      classname = testname,
                                      name = way)
             result = ET.SubElement(testcase, 'failure',
-                                   type = reason,
-                                   message = result)
+                                   type = 'unexpected failure',
+                                   message = escape(reason))
 
     for (directory, testname, reason, way) in t.framework_failures:
         testcase = ET.SubElement(testsuite, 'testcase',
                                  classname = testname,
-                                 name = way)
+                                 name = escape(way))
         result = ET.SubElement(testcase, 'error',
                                type = "framework failure",
-                               message = reason)
+                               message = escape(reason))
 
     for (directory, testname, way) in t.expected_passes:
         testcase = ET.SubElement(testsuite, 'testcase',
                                  classname = testname,
-                                 name = way)
+                                 name = escape(way))
 
     return ET.ElementTree(testsuites)