##// END OF EJS Templates
test-run-test: unset run-test specific environment variables...
Pierre-Yves David -
r24960:65e8dac7 stable
parent child Browse files
Show More
@@ -1,507 +1,514 b''
1 1 This file tests the behavior of run-tests.py itself.
2 2
3 Avoid interference from actual test env:
4
5 $ unset HGTEST_JOBS
6 $ unset HGTEST_TIMEOUT
7 $ unset HGTEST_PORT
8 $ unset HGTEST_SHELL
9
3 10 Smoke test
4 11 ============
5 12
6 13 $ $TESTDIR/run-tests.py $HGTEST_RUN_TESTS_PURE
7 14
8 15 # Ran 0 tests, 0 skipped, 0 warned, 0 failed.
9 16
10 17 a succesful test
11 18 =======================
12 19
13 20 $ cat > test-success.t << EOF
14 21 > $ echo babar
15 22 > babar
16 23 > $ echo xyzzy
17 24 > xyzzy
18 25 > EOF
19 26
20 27 $ $TESTDIR/run-tests.py --with-hg=`which hg`
21 28 .
22 29 # Ran 1 tests, 0 skipped, 0 warned, 0 failed.
23 30
24 31 failing test
25 32 ==================
26 33
27 34 $ cat > test-failure.t << EOF
28 35 > $ echo babar
29 36 > rataxes
30 37 > This is a noop statement so that
31 38 > this test is still more bytes than success.
32 39 > EOF
33 40
34 41 >>> fh = open('test-failure-unicode.t', 'wb')
35 42 >>> fh.write(u' $ echo babar\u03b1\n'.encode('utf-8'))
36 43 >>> fh.write(u' l\u03b5\u03b5t\n'.encode('utf-8'))
37 44
38 45 $ $TESTDIR/run-tests.py --with-hg=`which hg`
39 46
40 47 --- $TESTTMP/test-failure.t
41 48 +++ $TESTTMP/test-failure.t.err
42 49 @@ -1,4 +1,4 @@
43 50 $ echo babar
44 51 - rataxes
45 52 + babar
46 53 This is a noop statement so that
47 54 this test is still more bytes than success.
48 55
49 56 ERROR: test-failure.t output changed
50 57 !.
51 58 --- $TESTTMP/test-failure-unicode.t
52 59 +++ $TESTTMP/test-failure-unicode.t.err
53 60 @@ -1,2 +1,2 @@
54 61 $ echo babar\xce\xb1 (esc)
55 62 - l\xce\xb5\xce\xb5t (esc)
56 63 + babar\xce\xb1 (esc)
57 64
58 65 ERROR: test-failure-unicode.t output changed
59 66 !
60 67 Failed test-failure.t: output changed
61 68 Failed test-failure-unicode.t: output changed
62 69 # Ran 3 tests, 0 skipped, 0 warned, 2 failed.
63 70 python hash seed: * (glob)
64 71 [1]
65 72
66 73 test --xunit support
67 74 $ $TESTDIR/run-tests.py --with-hg=`which hg` --xunit=xunit.xml
68 75
69 76 --- $TESTTMP/test-failure.t
70 77 +++ $TESTTMP/test-failure.t.err
71 78 @@ -1,4 +1,4 @@
72 79 $ echo babar
73 80 - rataxes
74 81 + babar
75 82 This is a noop statement so that
76 83 this test is still more bytes than success.
77 84
78 85 ERROR: test-failure.t output changed
79 86 !.
80 87 --- $TESTTMP/test-failure-unicode.t
81 88 +++ $TESTTMP/test-failure-unicode.t.err
82 89 @@ -1,2 +1,2 @@
83 90 $ echo babar\xce\xb1 (esc)
84 91 - l\xce\xb5\xce\xb5t (esc)
85 92 + babar\xce\xb1 (esc)
86 93
87 94 ERROR: test-failure-unicode.t output changed
88 95 !
89 96 Failed test-failure.t: output changed
90 97 Failed test-failure-unicode.t: output changed
91 98 # Ran 3 tests, 0 skipped, 0 warned, 2 failed.
92 99 python hash seed: * (glob)
93 100 [1]
94 101 $ cat xunit.xml
95 102 <?xml version="1.0" encoding="utf-8"?>
96 103 <testsuite errors="0" failures="2" name="run-tests" skipped="0" tests="3">
97 104 <testcase name="test-success.t" time="*"/> (glob)
98 105 <testcase name="test-failure-unicode.t" time="*"> (glob)
99 106 <![CDATA[--- $TESTTMP/test-failure-unicode.t
100 107 +++ $TESTTMP/test-failure-unicode.t.err
101 108 @@ -1,2 +1,2 @@
102 109 $ echo babar\xce\xb1 (esc)
103 110 - l\xce\xb5\xce\xb5t (esc)
104 111 + babar\xce\xb1 (esc)
105 112 ]]> </testcase>
106 113 <testcase name="test-failure.t" time="*"> (glob)
107 114 <![CDATA[--- $TESTTMP/test-failure.t
108 115 +++ $TESTTMP/test-failure.t.err
109 116 @@ -1,4 +1,4 @@
110 117 $ echo babar
111 118 - rataxes
112 119 + babar
113 120 This is a noop statement so that
114 121 this test is still more bytes than success.
115 122 ]]> </testcase>
116 123 </testsuite>
117 124
118 125 $ rm test-failure-unicode.t
119 126
120 127 test for --retest
121 128 ====================
122 129
123 130 $ $TESTDIR/run-tests.py --with-hg=`which hg` --retest
124 131
125 132 --- $TESTTMP/test-failure.t
126 133 +++ $TESTTMP/test-failure.t.err
127 134 @@ -1,4 +1,4 @@
128 135 $ echo babar
129 136 - rataxes
130 137 + babar
131 138 This is a noop statement so that
132 139 this test is still more bytes than success.
133 140
134 141 ERROR: test-failure.t output changed
135 142 !
136 143 Failed test-failure.t: output changed
137 144 # Ran 2 tests, 1 skipped, 0 warned, 1 failed.
138 145 python hash seed: * (glob)
139 146 [1]
140 147
141 148 Selecting Tests To Run
142 149 ======================
143 150
144 151 successful
145 152
146 153 $ $TESTDIR/run-tests.py --with-hg=`which hg` test-success.t
147 154 .
148 155 # Ran 1 tests, 0 skipped, 0 warned, 0 failed.
149 156
150 157 success w/ keyword
151 158 $ $TESTDIR/run-tests.py --with-hg=`which hg` -k xyzzy
152 159 .
153 160 # Ran 2 tests, 1 skipped, 0 warned, 0 failed.
154 161
155 162 failed
156 163
157 164 $ $TESTDIR/run-tests.py --with-hg=`which hg` test-failure.t
158 165
159 166 --- $TESTTMP/test-failure.t
160 167 +++ $TESTTMP/test-failure.t.err
161 168 @@ -1,4 +1,4 @@
162 169 $ echo babar
163 170 - rataxes
164 171 + babar
165 172 This is a noop statement so that
166 173 this test is still more bytes than success.
167 174
168 175 ERROR: test-failure.t output changed
169 176 !
170 177 Failed test-failure.t: output changed
171 178 # Ran 1 tests, 0 skipped, 0 warned, 1 failed.
172 179 python hash seed: * (glob)
173 180 [1]
174 181
175 182 failure w/ keyword
176 183 $ $TESTDIR/run-tests.py --with-hg=`which hg` -k rataxes
177 184
178 185 --- $TESTTMP/test-failure.t
179 186 +++ $TESTTMP/test-failure.t.err
180 187 @@ -1,4 +1,4 @@
181 188 $ echo babar
182 189 - rataxes
183 190 + babar
184 191 This is a noop statement so that
185 192 this test is still more bytes than success.
186 193
187 194 ERROR: test-failure.t output changed
188 195 !
189 196 Failed test-failure.t: output changed
190 197 # Ran 2 tests, 1 skipped, 0 warned, 1 failed.
191 198 python hash seed: * (glob)
192 199 [1]
193 200
194 201 Verify that when a process fails to start we show a useful message
195 202 ==================================================================
196 203 NOTE: there is currently a bug where this shows "2 failed" even though
197 204 it's actually the same test being reported for failure twice.
198 205
199 206 $ cat > test-serve-fail.t <<EOF
200 207 > $ echo 'abort: child process failed to start blah'
201 208 > EOF
202 209 $ $TESTDIR/run-tests.py --with-hg=`which hg` test-serve-fail.t
203 210
204 211 ERROR: test-serve-fail.t output changed
205 212 !
206 213 ERROR: test-serve-fail.t output changed
207 214 !
208 215 Failed test-serve-fail.t: server failed to start (HGPORT=*) (glob)
209 216 Failed test-serve-fail.t: output changed
210 217 # Ran 1 tests, 0 skipped, 0 warned, 2 failed.
211 218 python hash seed: * (glob)
212 219 [1]
213 220 $ rm test-serve-fail.t
214 221
215 222 Running In Debug Mode
216 223 ======================
217 224
218 225 $ $TESTDIR/run-tests.py --with-hg=`which hg` --debug 2>&1 | grep -v pwd
219 226 + echo *SALT* 0 0 (glob)
220 227 *SALT* 0 0 (glob)
221 228 + echo babar
222 229 babar
223 230 + echo *SALT* 4 0 (glob)
224 231 *SALT* 4 0 (glob)
225 232 .+ echo *SALT* 0 0 (glob)
226 233 *SALT* 0 0 (glob)
227 234 + echo babar
228 235 babar
229 236 + echo *SALT* 2 0 (glob)
230 237 *SALT* 2 0 (glob)
231 238 + echo xyzzy
232 239 xyzzy
233 240 + echo *SALT* 4 0 (glob)
234 241 *SALT* 4 0 (glob)
235 242 .
236 243 # Ran 2 tests, 0 skipped, 0 warned, 0 failed.
237 244
238 245 Parallel runs
239 246 ==============
240 247
241 248 (duplicate the failing test to get predictable output)
242 249 $ cp test-failure.t test-failure-copy.t
243 250
244 251 $ $TESTDIR/run-tests.py --with-hg=`which hg` --jobs 2 test-failure*.t -n
245 252 !!
246 253 Failed test-failure*.t: output changed (glob)
247 254 Failed test-failure*.t: output changed (glob)
248 255 # Ran 2 tests, 0 skipped, 0 warned, 2 failed.
249 256 python hash seed: * (glob)
250 257 [1]
251 258
252 259 failures in parallel with --first should only print one failure
253 260 >>> f = open('test-nothing.t', 'w')
254 261 >>> f.write('foo\n' * 1024)
255 262 >>> f.write(' $ sleep 1')
256 263 $ $TESTDIR/run-tests.py --with-hg=`which hg` --jobs 2 --first
257 264
258 265 --- $TESTTMP/test-failure*.t (glob)
259 266 +++ $TESTTMP/test-failure*.t.err (glob)
260 267 @@ -1,4 +1,4 @@
261 268 $ echo babar
262 269 - rataxes
263 270 + babar
264 271 This is a noop statement so that
265 272 this test is still more bytes than success.
266 273
267 274 Failed test-failure*.t: output changed (glob)
268 275 Failed test-nothing.t: output changed
269 276 # Ran 2 tests, 0 skipped, 0 warned, 2 failed.
270 277 python hash seed: * (glob)
271 278 [1]
272 279
273 280
274 281 (delete the duplicated test file)
275 282 $ rm test-failure-copy.t test-nothing.t
276 283
277 284
278 285 Interactive run
279 286 ===============
280 287
281 288 (backup the failing test)
282 289 $ cp test-failure.t backup
283 290
284 291 Refuse the fix
285 292
286 293 $ echo 'n' | $TESTDIR/run-tests.py --with-hg=`which hg` -i
287 294
288 295 --- $TESTTMP/test-failure.t
289 296 +++ $TESTTMP/test-failure.t.err
290 297 @@ -1,4 +1,4 @@
291 298 $ echo babar
292 299 - rataxes
293 300 + babar
294 301 This is a noop statement so that
295 302 this test is still more bytes than success.
296 303 Accept this change? [n]
297 304 ERROR: test-failure.t output changed
298 305 !.
299 306 Failed test-failure.t: output changed
300 307 # Ran 2 tests, 0 skipped, 0 warned, 1 failed.
301 308 python hash seed: * (glob)
302 309 [1]
303 310
304 311 $ cat test-failure.t
305 312 $ echo babar
306 313 rataxes
307 314 This is a noop statement so that
308 315 this test is still more bytes than success.
309 316
310 317 Interactive with custom view
311 318
312 319 $ echo 'n' | $TESTDIR/run-tests.py --with-hg=`which hg` -i --view echo
313 320 $TESTTMP/test-failure.t $TESTTMP/test-failure.t.err (glob)
314 321 Accept this change? [n]* (glob)
315 322 ERROR: test-failure.t output changed
316 323 !.
317 324 Failed test-failure.t: output changed
318 325 # Ran 2 tests, 0 skipped, 0 warned, 1 failed.
319 326 python hash seed: * (glob)
320 327 [1]
321 328
322 329 View the fix
323 330
324 331 $ echo 'y' | $TESTDIR/run-tests.py --with-hg=`which hg` --view echo
325 332 $TESTTMP/test-failure.t $TESTTMP/test-failure.t.err (glob)
326 333
327 334 ERROR: test-failure.t output changed
328 335 !.
329 336 Failed test-failure.t: output changed
330 337 # Ran 2 tests, 0 skipped, 0 warned, 1 failed.
331 338 python hash seed: * (glob)
332 339 [1]
333 340
334 341 Accept the fix
335 342
336 343 $ echo " $ echo 'saved backup bundle to \$TESTTMP/foo.hg'" >> test-failure.t
337 344 $ echo " saved backup bundle to \$TESTTMP/foo.hg" >> test-failure.t
338 345 $ echo " $ echo 'saved backup bundle to \$TESTTMP/foo.hg'" >> test-failure.t
339 346 $ echo " saved backup bundle to \$TESTTMP/foo.hg (glob)" >> test-failure.t
340 347 $ echo " $ echo 'saved backup bundle to \$TESTTMP/foo.hg'" >> test-failure.t
341 348 $ echo " saved backup bundle to \$TESTTMP/*.hg (glob)" >> test-failure.t
342 349 $ echo 'y' | $TESTDIR/run-tests.py --with-hg=`which hg` -i 2>&1 | \
343 350 > sed -e 's,(glob)$,&<,g'
344 351
345 352 --- $TESTTMP/test-failure.t
346 353 +++ $TESTTMP/test-failure.t.err
347 354 @@ -1,9 +1,9 @@
348 355 $ echo babar
349 356 - rataxes
350 357 + babar
351 358 This is a noop statement so that
352 359 this test is still more bytes than success.
353 360 $ echo 'saved backup bundle to $TESTTMP/foo.hg'
354 361 - saved backup bundle to $TESTTMP/foo.hg
355 362 + saved backup bundle to $TESTTMP/foo.hg (glob)<
356 363 $ echo 'saved backup bundle to $TESTTMP/foo.hg'
357 364 saved backup bundle to $TESTTMP/foo.hg (glob)<
358 365 $ echo 'saved backup bundle to $TESTTMP/foo.hg'
359 366 Accept this change? [n] ..
360 367 # Ran 2 tests, 0 skipped, 0 warned, 0 failed.
361 368
362 369 $ sed -e 's,(glob)$,&<,g' test-failure.t
363 370 $ echo babar
364 371 babar
365 372 This is a noop statement so that
366 373 this test is still more bytes than success.
367 374 $ echo 'saved backup bundle to $TESTTMP/foo.hg'
368 375 saved backup bundle to $TESTTMP/foo.hg (glob)<
369 376 $ echo 'saved backup bundle to $TESTTMP/foo.hg'
370 377 saved backup bundle to $TESTTMP/foo.hg (glob)<
371 378 $ echo 'saved backup bundle to $TESTTMP/foo.hg'
372 379 saved backup bundle to $TESTTMP/*.hg (glob)<
373 380
374 381 (reinstall)
375 382 $ mv backup test-failure.t
376 383
377 384 No Diff
378 385 ===============
379 386
380 387 $ $TESTDIR/run-tests.py --with-hg=`which hg` --nodiff
381 388 !.
382 389 Failed test-failure.t: output changed
383 390 # Ran 2 tests, 0 skipped, 0 warned, 1 failed.
384 391 python hash seed: * (glob)
385 392 [1]
386 393
387 394 test for --time
388 395 ==================
389 396
390 397 $ $TESTDIR/run-tests.py --with-hg=`which hg` test-success.t --time
391 398 .
392 399 # Ran 1 tests, 0 skipped, 0 warned, 0 failed.
393 400 # Producing time report
394 401 cuser csys real Test
395 402 \s*[\d\.]{5} \s*[\d\.]{5} \s*[\d\.]{5} test-success.t (re)
396 403
397 404 test for --time with --job enabled
398 405 ====================================
399 406
400 407 $ $TESTDIR/run-tests.py --with-hg=`which hg` test-success.t --time --jobs 2
401 408 .
402 409 # Ran 1 tests, 0 skipped, 0 warned, 0 failed.
403 410 # Producing time report
404 411 cuser csys real Test
405 412 \s*[\d\.]{5} \s*[\d\.]{5} \s*[\d\.]{5} test-success.t (re)
406 413
407 414 Skips
408 415 ================
409 416 $ cat > test-skip.t <<EOF
410 417 > $ echo xyzzy
411 418 > #require false
412 419 > EOF
413 420 $ $TESTDIR/run-tests.py --with-hg=`which hg` --nodiff
414 421 !.s
415 422 Skipped test-skip.t: skipped
416 423 Failed test-failure.t: output changed
417 424 # Ran 2 tests, 1 skipped, 0 warned, 1 failed.
418 425 python hash seed: * (glob)
419 426 [1]
420 427
421 428 $ $TESTDIR/run-tests.py --with-hg=`which hg` --keyword xyzzy
422 429 .s
423 430 Skipped test-skip.t: skipped
424 431 # Ran 2 tests, 2 skipped, 0 warned, 0 failed.
425 432
426 433 Skips with xml
427 434 $ $TESTDIR/run-tests.py --with-hg=`which hg` --keyword xyzzy \
428 435 > --xunit=xunit.xml
429 436 .s
430 437 Skipped test-skip.t: skipped
431 438 # Ran 2 tests, 2 skipped, 0 warned, 0 failed.
432 439 $ cat xunit.xml
433 440 <?xml version="1.0" encoding="utf-8"?>
434 441 <testsuite errors="0" failures="0" name="run-tests" skipped="2" tests="2">
435 442 <testcase name="test-success.t" time="*"/> (glob)
436 443 </testsuite>
437 444
438 445 Missing skips or blacklisted skips don't count as executed:
439 446 $ echo test-failure.t > blacklist
440 447 $ $TESTDIR/run-tests.py --with-hg=`which hg` --blacklist=blacklist \
441 448 > test-failure.t test-bogus.t
442 449 ss
443 450 Skipped test-bogus.t: Doesn't exist
444 451 Skipped test-failure.t: blacklisted
445 452 # Ran 0 tests, 2 skipped, 0 warned, 0 failed.
446 453
447 454 #if json
448 455
449 456 test for --json
450 457 ==================
451 458
452 459 $ $TESTDIR/run-tests.py --with-hg=`which hg` --json
453 460
454 461 --- $TESTTMP/test-failure.t
455 462 +++ $TESTTMP/test-failure.t.err
456 463 @@ -1,4 +1,4 @@
457 464 $ echo babar
458 465 - rataxes
459 466 + babar
460 467 This is a noop statement so that
461 468 this test is still more bytes than success.
462 469
463 470 ERROR: test-failure.t output changed
464 471 !.s
465 472 Skipped test-skip.t: skipped
466 473 Failed test-failure.t: output changed
467 474 # Ran 2 tests, 1 skipped, 0 warned, 1 failed.
468 475 python hash seed: * (glob)
469 476 [1]
470 477
471 478 $ cat report.json
472 479 testreport ={
473 480 "test-failure.t": [\{] (re)
474 481 "csys": "\s*[\d\.]{4,5}", ? (re)
475 482 "cuser": "\s*[\d\.]{4,5}", ? (re)
476 483 "result": "failure", ? (re)
477 484 "time": "\s*[\d\.]{4,5}" (re)
478 485 }, ? (re)
479 486 "test-skip.t": {
480 487 "csys": "\s*[\d\.]{4,5}", ? (re)
481 488 "cuser": "\s*[\d\.]{4,5}", ? (re)
482 489 "result": "skip", ? (re)
483 490 "time": "\s*[\d\.]{4,5}" (re)
484 491 }, ? (re)
485 492 "test-success.t": [\{] (re)
486 493 "csys": "\s*[\d\.]{4,5}", ? (re)
487 494 "cuser": "\s*[\d\.]{4,5}", ? (re)
488 495 "result": "success", ? (re)
489 496 "time": "\s*[\d\.]{4,5}" (re)
490 497 }
491 498 } (no-eol)
492 499
493 500 #endif
494 501
495 502 backslash on end of line with glob matching is handled properly
496 503
497 504 $ cat > test-glob-backslash.t << EOF
498 505 > $ echo 'foo bar \\'
499 506 > foo * \ (glob)
500 507 > EOF
501 508
502 509 $ $TESTDIR/run-tests.py --with-hg=`which hg` test-glob-backslash.t
503 510 .
504 511 # Ran 1 tests, 0 skipped, 0 warned, 0 failed.
505 512
506 513 $ rm -f test-glob-backslash.t
507 514
General Comments 0
You need to be logged in to leave comments. Login now