##// END OF EJS Templates
run-tests: wrap failures in an XUnit 'failure' element...
Siddharth Agarwal -
r32714:ef8d2453 default
parent child Browse files
Show More
@@ -2024,6 +2024,7 b' class TextTestRunner(unittest.TextTestRu'
2024
2024
2025 @staticmethod
2025 @staticmethod
2026 def _writexunit(result, outf):
2026 def _writexunit(result, outf):
2027 # See http://llg.cubic.org/docs/junit/ for a reference.
2027 timesd = dict((t[0], t[3]) for t in result.times)
2028 timesd = dict((t[0], t[3]) for t in result.times)
2028 doc = minidom.Document()
2029 doc = minidom.Document()
2029 s = doc.createElement('testsuite')
2030 s = doc.createElement('testsuite')
@@ -2052,7 +2053,13 b' class TextTestRunner(unittest.TextTestRu'
2052 # fail if string isn't ASCII.
2053 # fail if string isn't ASCII.
2053 err = cdatasafe(err).decode('utf-8', 'replace')
2054 err = cdatasafe(err).decode('utf-8', 'replace')
2054 cd = doc.createCDATASection(err)
2055 cd = doc.createCDATASection(err)
2055 t.appendChild(cd)
2056 # Use 'failure' here instead of 'error' to match errors = 0,
2057 # failures = len(result.failures) in the testsuite element.
2058 failelem = doc.createElement('failure')
2059 failelem.setAttribute('message', 'output changed')
2060 failelem.setAttribute('type', 'output-mismatch')
2061 failelem.appendChild(cd)
2062 t.appendChild(failelem)
2056 s.appendChild(t)
2063 s.appendChild(t)
2057 outf.write(doc.toprettyxml(indent=' ', encoding='utf-8'))
2064 outf.write(doc.toprettyxml(indent=' ', encoding='utf-8'))
2058
2065
@@ -200,14 +200,17 b' test --xunit support'
200 <testsuite errors="0" failures="2" name="run-tests" skipped="0" tests="3">
200 <testsuite errors="0" failures="2" name="run-tests" skipped="0" tests="3">
201 <testcase name="test-success.t" time="*"/> (glob)
201 <testcase name="test-success.t" time="*"/> (glob)
202 <testcase name="test-failure-unicode.t" time="*"> (glob)
202 <testcase name="test-failure-unicode.t" time="*"> (glob)
203 <failure message="output changed" type="output-mismatch">
203 <![CDATA[--- $TESTTMP/test-failure-unicode.t
204 <![CDATA[--- $TESTTMP/test-failure-unicode.t
204 +++ $TESTTMP/test-failure-unicode.t.err
205 +++ $TESTTMP/test-failure-unicode.t.err
205 @@ -1,2 +1,2 @@
206 @@ -1,2 +1,2 @@
206 $ echo babar\xce\xb1 (esc)
207 $ echo babar\xce\xb1 (esc)
207 - l\xce\xb5\xce\xb5t (esc)
208 - l\xce\xb5\xce\xb5t (esc)
208 + babar\xce\xb1 (esc)
209 + babar\xce\xb1 (esc)
209 ]]> </testcase>
210 ]]> </failure>
211 </testcase>
210 <testcase name="test-failure.t" time="*"> (glob)
212 <testcase name="test-failure.t" time="*"> (glob)
213 <failure message="output changed" type="output-mismatch">
211 <![CDATA[--- $TESTTMP/test-failure.t
214 <![CDATA[--- $TESTTMP/test-failure.t
212 +++ $TESTTMP/test-failure.t.err
215 +++ $TESTTMP/test-failure.t.err
213 @@ -1,5 +1,5 @@
216 @@ -1,5 +1,5 @@
@@ -217,7 +220,8 b' test --xunit support'
217 This is a noop statement so that
220 This is a noop statement so that
218 this test is still more bytes than success.
221 this test is still more bytes than success.
219 pad pad pad pad............................................................
222 pad pad pad pad............................................................
220 ]]> </testcase>
223 ]]> </failure>
224 </testcase>
221 </testsuite>
225 </testsuite>
222
226
223 $ cat .testtimes
227 $ cat .testtimes
General Comments 0
You need to be logged in to leave comments. Login now