Mercurial > hg
comparison tests/test-run-tests.t @ 24500:7b0a20cd8c95
run-tests: explicitly handle unicode when writing xunit file
The xunit writer was passing a str to a minidom API. An implicit
.decode('ascii') was performed somewhere, causing UnicodeDecodeError
if test output contained non-ascii sequences.
This patch converts test output to utf-8 before passing it to minidom.
We use the "replace" strategy to ensure invalid utf-8 sequences get
munged into �.
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sun, 29 Mar 2015 10:41:23 -0700 |
parents | d64dd1252386 |
children | a0668a587c04 |
comparison
equal
deleted
inserted
replaced
24499:90db70de6f9c | 24500:7b0a20cd8c95 |
---|---|
29 > rataxes | 29 > rataxes |
30 > This is a noop statement so that | 30 > This is a noop statement so that |
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 |
37 +++ $TESTTMP/test-failure.t.err | 41 +++ $TESTTMP/test-failure.t.err |
38 @@ -1,4 +1,4 @@ | 42 @@ -1,4 +1,4 @@ |
42 This is a noop statement so that | 46 This is a noop statement so that |
43 this test is still more bytes than success. | 47 this test is still more bytes than success. |
44 | 48 |
45 ERROR: test-failure.t output changed | 49 ERROR: test-failure.t output changed |
46 !. | 50 !. |
47 Failed test-failure.t: output changed | 51 --- $TESTTMP/test-failure-unicode.t |
48 # Ran 2 tests, 0 skipped, 0 warned, 1 failed. | 52 +++ $TESTTMP/test-failure-unicode.t.err |
49 python hash seed: * (glob) | 53 @@ -1,2 +1,2 @@ |
50 [1] | 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 ! | |
60 Failed test-failure.t: output changed | |
61 Failed test-failure-unicode.t: output changed | |
62 # Ran 3 tests, 0 skipped, 0 warned, 2 failed. | |
63 python hash seed: * (glob) | |
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 |
54 --- $TESTTMP/test-failure.t | 69 --- $TESTTMP/test-failure.t |
55 +++ $TESTTMP/test-failure.t.err | 70 +++ $TESTTMP/test-failure.t.err |
60 This is a noop statement so that | 75 This is a noop statement so that |
61 this test is still more bytes than success. | 76 this test is still more bytes than success. |
62 | 77 |
63 ERROR: test-failure.t output changed | 78 ERROR: test-failure.t output changed |
64 !. | 79 !. |
65 Failed test-failure.t: output changed | 80 --- $TESTTMP/test-failure-unicode.t |
66 # Ran 2 tests, 0 skipped, 0 warned, 1 failed. | 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 ! | |
89 Failed test-failure.t: output changed | |
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 |
76 @@ -1,4 +1,4 @@ | 109 @@ -1,4 +1,4 @@ |
77 $ echo babar | 110 $ echo babar |
79 + babar | 112 + babar |
80 This is a noop statement so that | 113 This is a noop statement so that |
81 this test is still more bytes than success. | 114 this test is still more bytes than success. |
82 ]]> </testcase> | 115 ]]> </testcase> |
83 </testsuite> | 116 </testsuite> |
117 | |
118 $ rm test-failure-unicode.t | |
84 | 119 |
85 test for --retest | 120 test for --retest |
86 ==================== | 121 ==================== |
87 | 122 |
88 $ $TESTDIR/run-tests.py --with-hg=`which hg` --retest | 123 $ $TESTDIR/run-tests.py --with-hg=`which hg` --retest |