diff tests/run-tests.py @ 32714:ef8d24539612

run-tests: wrap failures in an XUnit 'failure' element This is closer to what most XUnit consumers can understand.
author Siddharth Agarwal <sid0@fb.com>
date Wed, 07 Jun 2017 15:47:06 -0700
parents 04c19c808241
children a4d0e816a672
line wrap: on
line diff
--- a/tests/run-tests.py	Wed Jun 07 10:44:11 2017 +0100
+++ b/tests/run-tests.py	Wed Jun 07 15:47:06 2017 -0700
@@ -2024,6 +2024,7 @@
 
     @staticmethod
     def _writexunit(result, outf):
+        # See http://llg.cubic.org/docs/junit/ for a reference.
         timesd = dict((t[0], t[3]) for t in result.times)
         doc = minidom.Document()
         s = doc.createElement('testsuite')
@@ -2052,7 +2053,13 @@
             # fail if string isn't ASCII.
             err = cdatasafe(err).decode('utf-8', 'replace')
             cd = doc.createCDATASection(err)
-            t.appendChild(cd)
+            # Use 'failure' here instead of 'error' to match errors = 0,
+            # failures = len(result.failures) in the testsuite element.
+            failelem = doc.createElement('failure')
+            failelem.setAttribute('message', 'output changed')
+            failelem.setAttribute('type', 'output-mismatch')
+            failelem.appendChild(cd)
+            t.appendChild(failelem)
             s.appendChild(t)
         outf.write(doc.toprettyxml(indent='  ', encoding='utf-8'))