##// END OF EJS Templates
run-tests: explicitly handle unicode when writing xunit file...
Gregory Szorc -
r24500:7b0a20cd default
parent child Browse files
Show More
@@ -1469,7 +1469,11 b' class TextTestRunner(unittest.TextTestRu'
1469 t = doc.createElement('testcase')
1469 t = doc.createElement('testcase')
1470 t.setAttribute('name', tc)
1470 t.setAttribute('name', tc)
1471 t.setAttribute('time', '%.3f' % timesd[tc])
1471 t.setAttribute('time', '%.3f' % timesd[tc])
1472 cd = doc.createCDATASection(cdatasafe(err))
1472 # createCDATASection expects a unicode or it will convert
1473 # using default conversion rules, which will fail if
1474 # string isn't ASCII.
1475 err = cdatasafe(err).decode('utf-8', 'replace')
1476 cd = doc.createCDATASection(err)
1473 t.appendChild(cd)
1477 t.appendChild(cd)
1474 s.appendChild(t)
1478 s.appendChild(t)
1475 xuf.write(doc.toprettyxml(indent=' ', encoding='utf-8'))
1479 xuf.write(doc.toprettyxml(indent=' ', encoding='utf-8'))
@@ -31,6 +31,10 b' failing test'
31 > this test is still more bytes than success.
31 > this test is still more bytes than success.
32 > EOF
32 > EOF
33
33
34 >>> fh = open('test-failure-unicode.t', 'wb')
35 >>> fh.write(u' $ echo babar\u03b1\n'.encode('utf-8'))
36 >>> fh.write(u' l\u03b5\u03b5t\n'.encode('utf-8'))
37
34 $ $TESTDIR/run-tests.py --with-hg=`which hg`
38 $ $TESTDIR/run-tests.py --with-hg=`which hg`
35
39
36 --- $TESTTMP/test-failure.t
40 --- $TESTTMP/test-failure.t
@@ -44,10 +48,21 b' failing test'
44
48
45 ERROR: test-failure.t output changed
49 ERROR: test-failure.t output changed
46 !.
50 !.
51 --- $TESTTMP/test-failure-unicode.t
52 +++ $TESTTMP/test-failure-unicode.t.err
53 @@ -1,2 +1,2 @@
54 $ echo babar\xce\xb1 (esc)
55 - l\xce\xb5\xce\xb5t (esc)
56 + babar\xce\xb1 (esc)
57
58 ERROR: test-failure-unicode.t output changed
59 !
47 Failed test-failure.t: output changed
60 Failed test-failure.t: output changed
48 # Ran 2 tests, 0 skipped, 0 warned, 1 failed.
61 Failed test-failure-unicode.t: output changed
62 # Ran 3 tests, 0 skipped, 0 warned, 2 failed.
49 python hash seed: * (glob)
63 python hash seed: * (glob)
50 [1]
64 [1]
65
51 test --xunit support
66 test --xunit support
52 $ $TESTDIR/run-tests.py --with-hg=`which hg` --xunit=xunit.xml
67 $ $TESTDIR/run-tests.py --with-hg=`which hg` --xunit=xunit.xml
53
68
@@ -62,14 +77,32 b' test --xunit support'
62
77
63 ERROR: test-failure.t output changed
78 ERROR: test-failure.t output changed
64 !.
79 !.
80 --- $TESTTMP/test-failure-unicode.t
81 +++ $TESTTMP/test-failure-unicode.t.err
82 @@ -1,2 +1,2 @@
83 $ echo babar\xce\xb1 (esc)
84 - l\xce\xb5\xce\xb5t (esc)
85 + babar\xce\xb1 (esc)
86
87 ERROR: test-failure-unicode.t output changed
88 !
65 Failed test-failure.t: output changed
89 Failed test-failure.t: output changed
66 # Ran 2 tests, 0 skipped, 0 warned, 1 failed.
90 Failed test-failure-unicode.t: output changed
91 # Ran 3 tests, 0 skipped, 0 warned, 2 failed.
67 python hash seed: * (glob)
92 python hash seed: * (glob)
68 [1]
93 [1]
69 $ cat xunit.xml
94 $ cat xunit.xml
70 <?xml version="1.0" encoding="utf-8"?>
95 <?xml version="1.0" encoding="utf-8"?>
71 <testsuite errors="0" failures="1" name="run-tests" skipped="0" tests="2">
96 <testsuite errors="0" failures="2" name="run-tests" skipped="0" tests="3">
72 <testcase name="test-success.t" time="*"/> (glob)
97 <testcase name="test-success.t" time="*"/> (glob)
98 <testcase name="test-failure-unicode.t" time="*"> (glob)
99 <![CDATA[--- $TESTTMP/test-failure-unicode.t
100 +++ $TESTTMP/test-failure-unicode.t.err
101 @@ -1,2 +1,2 @@
102 $ echo babar\xce\xb1 (esc)
103 - l\xce\xb5\xce\xb5t (esc)
104 + babar\xce\xb1 (esc)
105 ]]> </testcase>
73 <testcase name="test-failure.t" time="*"> (glob)
106 <testcase name="test-failure.t" time="*"> (glob)
74 <![CDATA[--- $TESTTMP/test-failure.t
107 <![CDATA[--- $TESTTMP/test-failure.t
75 +++ $TESTTMP/test-failure.t.err
108 +++ $TESTTMP/test-failure.t.err
@@ -82,6 +115,8 b' test --xunit support'
82 ]]> </testcase>
115 ]]> </testcase>
83 </testsuite>
116 </testsuite>
84
117
118 $ rm test-failure-unicode.t
119
85 test for --retest
120 test for --retest
86 ====================
121 ====================
87
122
General Comments 0
You need to be logged in to leave comments. Login now