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