##// END OF EJS Templates
tests: de-flake test-run-tests.t's "--jobs=2 --first" test...
Martin von Zweigbergk -
r34895:b63a7d83 default
parent child Browse files
Show More
@@ -1,1474 +1,1471 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 $ . "$TESTDIR/helper-runtests.sh"
6 6
7 7 Smoke test with install
8 8 ============
9 9
10 10 $ run-tests.py $HGTEST_RUN_TESTS_PURE -l
11 11
12 12 # Ran 0 tests, 0 skipped, 0 failed.
13 13
14 14 Define a helper to avoid the install step
15 15 =============
16 16 $ rt()
17 17 > {
18 18 > run-tests.py --with-hg=`which hg` "$@"
19 19 > }
20 20
21 21 error paths
22 22
23 23 #if symlink
24 24 $ ln -s `which true` hg
25 25 $ run-tests.py --with-hg=./hg
26 26 warning: --with-hg should specify an hg script
27 27
28 28 # Ran 0 tests, 0 skipped, 0 failed.
29 29 $ rm hg
30 30 #endif
31 31
32 32 #if execbit
33 33 $ touch hg
34 34 $ run-tests.py --with-hg=./hg
35 35 Usage: run-tests.py [options] [tests]
36 36
37 37 run-tests.py: error: --with-hg must specify an executable hg script
38 38 [2]
39 39 $ rm hg
40 40 #endif
41 41
42 42 Features for testing optional lines
43 43 ===================================
44 44
45 45 $ cat > hghaveaddon.py <<EOF
46 46 > import hghave
47 47 > @hghave.check("custom", "custom hghave feature")
48 48 > def has_custom():
49 49 > return True
50 50 > @hghave.check("missing", "missing hghave feature")
51 51 > def has_missing():
52 52 > return False
53 53 > EOF
54 54
55 55 an empty test
56 56 =======================
57 57
58 58 $ touch test-empty.t
59 59 $ rt
60 60 .
61 61 # Ran 1 tests, 0 skipped, 0 failed.
62 62 $ rm test-empty.t
63 63
64 64 a succesful test
65 65 =======================
66 66
67 67 $ cat > test-success.t << EOF
68 68 > $ echo babar
69 69 > babar
70 70 > $ echo xyzzy
71 71 > dont_print (?)
72 72 > nothing[42]line (re) (?)
73 73 > never*happens (glob) (?)
74 74 > more_nothing (?)
75 75 > xyzzy
76 76 > nor this (?)
77 77 > $ printf 'abc\ndef\nxyz\n'
78 78 > 123 (?)
79 79 > abc
80 80 > def (?)
81 81 > 456 (?)
82 82 > xyz
83 83 > $ printf 'zyx\nwvu\ntsr\n'
84 84 > abc (?)
85 85 > zyx (custom !)
86 86 > wvu
87 87 > no_print (no-custom !)
88 88 > tsr (no-missing !)
89 89 > missing (missing !)
90 90 > EOF
91 91
92 92 $ rt
93 93 .
94 94 # Ran 1 tests, 0 skipped, 0 failed.
95 95
96 96 failing test
97 97 ==================
98 98
99 99 test churn with globs
100 100 $ cat > test-failure.t <<EOF
101 101 > $ echo "bar-baz"; echo "bar-bad"
102 102 > bar*bad (glob)
103 103 > bar*baz (glob)
104 104 > EOF
105 105 $ rt test-failure.t
106 106
107 107 --- $TESTTMP/test-failure.t
108 108 +++ $TESTTMP/test-failure.t.err
109 109 @@ -1,3 +1,3 @@
110 110 $ echo "bar-baz"; echo "bar-bad"
111 111 + bar*baz (glob)
112 112 bar*bad (glob)
113 113 - bar*baz (glob)
114 114
115 115 ERROR: test-failure.t output changed
116 116 !
117 117 Failed test-failure.t: output changed
118 118 # Ran 1 tests, 0 skipped, 1 failed.
119 119 python hash seed: * (glob)
120 120 [1]
121 121
122 122 test diff colorisation
123 123
124 124 #if no-windows pygments
125 125 $ rt test-failure.t --color always
126 126
127 127 \x1b[38;5;124m--- $TESTTMP/test-failure.t\x1b[39m (esc)
128 128 \x1b[38;5;34m+++ $TESTTMP/test-failure.t.err\x1b[39m (esc)
129 129 \x1b[38;5;90;01m@@ -1,3 +1,3 @@\x1b[39;00m (esc)
130 130 $ echo "bar-baz"; echo "bar-bad"
131 131 \x1b[38;5;34m+ bar*baz (glob)\x1b[39m (esc)
132 132 bar*bad (glob)
133 133 \x1b[38;5;124m- bar*baz (glob)\x1b[39m (esc)
134 134
135 135 \x1b[38;5;88mERROR: \x1b[39m\x1b[38;5;9mtest-failure.t\x1b[39m\x1b[38;5;88m output changed\x1b[39m (esc)
136 136 !
137 137 \x1b[38;5;88mFailed \x1b[39m\x1b[38;5;9mtest-failure.t\x1b[39m\x1b[38;5;88m: output changed\x1b[39m (esc)
138 138 # Ran 1 tests, 0 skipped, 1 failed.
139 139 python hash seed: * (glob)
140 140 [1]
141 141
142 142 $ rt test-failure.t 2> tmp.log
143 143 [1]
144 144 $ cat tmp.log
145 145
146 146 --- $TESTTMP/test-failure.t
147 147 +++ $TESTTMP/test-failure.t.err
148 148 @@ -1,3 +1,3 @@
149 149 $ echo "bar-baz"; echo "bar-bad"
150 150 + bar*baz (glob)
151 151 bar*bad (glob)
152 152 - bar*baz (glob)
153 153
154 154 ERROR: test-failure.t output changed
155 155 !
156 156 Failed test-failure.t: output changed
157 157 # Ran 1 tests, 0 skipped, 1 failed.
158 158 python hash seed: * (glob)
159 159 #endif
160 160
161 161 $ cat > test-failure.t << EOF
162 162 > $ true
163 163 > should go away (true !)
164 164 > $ true
165 165 > should stay (false !)
166 166 >
167 167 > Should remove first line, not second or third
168 168 > $ echo 'testing'
169 169 > baz*foo (glob) (true !)
170 170 > foobar*foo (glob) (false !)
171 171 > te*ting (glob) (true !)
172 172 >
173 173 > Should keep first two lines, remove third and last
174 174 > $ echo 'testing'
175 175 > test.ng (re) (true !)
176 176 > foo.ar (re) (false !)
177 177 > b.r (re) (true !)
178 178 > missing (?)
179 179 > awol (true !)
180 180 >
181 181 > The "missing" line should stay, even though awol is dropped
182 182 > $ echo 'testing'
183 183 > test.ng (re) (true !)
184 184 > foo.ar (?)
185 185 > awol
186 186 > missing (?)
187 187 > EOF
188 188 $ rt test-failure.t
189 189
190 190 --- $TESTTMP/test-failure.t
191 191 +++ $TESTTMP/test-failure.t.err
192 192 @@ -1,11 +1,9 @@
193 193 $ true
194 194 - should go away (true !)
195 195 $ true
196 196 should stay (false !)
197 197
198 198 Should remove first line, not second or third
199 199 $ echo 'testing'
200 200 - baz*foo (glob) (true !)
201 201 foobar*foo (glob) (false !)
202 202 te*ting (glob) (true !)
203 203
204 204 foo.ar (re) (false !)
205 205 missing (?)
206 206 @@ -13,13 +11,10 @@
207 207 $ echo 'testing'
208 208 test.ng (re) (true !)
209 209 foo.ar (re) (false !)
210 210 - b.r (re) (true !)
211 211 missing (?)
212 212 - awol (true !)
213 213
214 214 The "missing" line should stay, even though awol is dropped
215 215 $ echo 'testing'
216 216 test.ng (re) (true !)
217 217 foo.ar (?)
218 218 - awol
219 219 missing (?)
220 220
221 221 ERROR: test-failure.t output changed
222 222 !
223 223 Failed test-failure.t: output changed
224 224 # Ran 1 tests, 0 skipped, 1 failed.
225 225 python hash seed: * (glob)
226 226 [1]
227 227
228 228 basic failing test
229 229 $ cat > test-failure.t << EOF
230 230 > $ echo babar
231 231 > rataxes
232 232 > This is a noop statement so that
233 233 > this test is still more bytes than success.
234 234 > pad pad pad pad............................................................
235 235 > pad pad pad pad............................................................
236 236 > pad pad pad pad............................................................
237 237 > pad pad pad pad............................................................
238 238 > pad pad pad pad............................................................
239 239 > pad pad pad pad............................................................
240 240 > EOF
241 241
242 242 >>> fh = open('test-failure-unicode.t', 'wb')
243 243 >>> fh.write(u' $ echo babar\u03b1\n'.encode('utf-8')) and None
244 244 >>> fh.write(u' l\u03b5\u03b5t\n'.encode('utf-8')) and None
245 245
246 246 $ rt
247 247
248 248 --- $TESTTMP/test-failure.t
249 249 +++ $TESTTMP/test-failure.t.err
250 250 @@ -1,5 +1,5 @@
251 251 $ echo babar
252 252 - rataxes
253 253 + babar
254 254 This is a noop statement so that
255 255 this test is still more bytes than success.
256 256 pad pad pad pad............................................................
257 257
258 258 ERROR: test-failure.t output changed
259 259 !.
260 260 --- $TESTTMP/test-failure-unicode.t
261 261 +++ $TESTTMP/test-failure-unicode.t.err
262 262 @@ -1,2 +1,2 @@
263 263 $ echo babar\xce\xb1 (esc)
264 264 - l\xce\xb5\xce\xb5t (esc)
265 265 + babar\xce\xb1 (esc)
266 266
267 267 ERROR: test-failure-unicode.t output changed
268 268 !
269 269 Failed test-failure.t: output changed
270 270 Failed test-failure-unicode.t: output changed
271 271 # Ran 3 tests, 0 skipped, 2 failed.
272 272 python hash seed: * (glob)
273 273 [1]
274 274
275 275 test --outputdir
276 276 $ mkdir output
277 277 $ rt --outputdir output
278 278
279 279 --- $TESTTMP/test-failure.t
280 280 +++ $TESTTMP/output/test-failure.t.err
281 281 @@ -1,5 +1,5 @@
282 282 $ echo babar
283 283 - rataxes
284 284 + babar
285 285 This is a noop statement so that
286 286 this test is still more bytes than success.
287 287 pad pad pad pad............................................................
288 288
289 289 ERROR: test-failure.t output changed
290 290 !.
291 291 --- $TESTTMP/test-failure-unicode.t
292 292 +++ $TESTTMP/output/test-failure-unicode.t.err
293 293 @@ -1,2 +1,2 @@
294 294 $ echo babar\xce\xb1 (esc)
295 295 - l\xce\xb5\xce\xb5t (esc)
296 296 + babar\xce\xb1 (esc)
297 297
298 298 ERROR: test-failure-unicode.t output changed
299 299 !
300 300 Failed test-failure.t: output changed
301 301 Failed test-failure-unicode.t: output changed
302 302 # Ran 3 tests, 0 skipped, 2 failed.
303 303 python hash seed: * (glob)
304 304 [1]
305 305 $ ls -a output
306 306 .
307 307 ..
308 308 .testtimes
309 309 test-failure-unicode.t.err
310 310 test-failure.t.err
311 311
312 312 test --xunit support
313 313 $ rt --xunit=xunit.xml
314 314
315 315 --- $TESTTMP/test-failure.t
316 316 +++ $TESTTMP/test-failure.t.err
317 317 @@ -1,5 +1,5 @@
318 318 $ echo babar
319 319 - rataxes
320 320 + babar
321 321 This is a noop statement so that
322 322 this test is still more bytes than success.
323 323 pad pad pad pad............................................................
324 324
325 325 ERROR: test-failure.t output changed
326 326 !.
327 327 --- $TESTTMP/test-failure-unicode.t
328 328 +++ $TESTTMP/test-failure-unicode.t.err
329 329 @@ -1,2 +1,2 @@
330 330 $ echo babar\xce\xb1 (esc)
331 331 - l\xce\xb5\xce\xb5t (esc)
332 332 + babar\xce\xb1 (esc)
333 333
334 334 ERROR: test-failure-unicode.t output changed
335 335 !
336 336 Failed test-failure.t: output changed
337 337 Failed test-failure-unicode.t: output changed
338 338 # Ran 3 tests, 0 skipped, 2 failed.
339 339 python hash seed: * (glob)
340 340 [1]
341 341 $ cat xunit.xml
342 342 <?xml version="1.0" encoding="utf-8"?>
343 343 <testsuite errors="0" failures="2" name="run-tests" skipped="0" tests="3">
344 344 <testcase name="test-success.t" time="*"/> (glob)
345 345 <testcase name="test-failure-unicode.t" time="*"> (glob)
346 346 <failure message="output changed" type="output-mismatch">
347 347 <![CDATA[--- $TESTTMP/test-failure-unicode.t
348 348 +++ $TESTTMP/test-failure-unicode.t.err
349 349 @@ -1,2 +1,2 @@
350 350 $ echo babar\xce\xb1 (esc)
351 351 - l\xce\xb5\xce\xb5t (esc)
352 352 + babar\xce\xb1 (esc)
353 353 ]]> </failure>
354 354 </testcase>
355 355 <testcase name="test-failure.t" time="*"> (glob)
356 356 <failure message="output changed" type="output-mismatch">
357 357 <![CDATA[--- $TESTTMP/test-failure.t
358 358 +++ $TESTTMP/test-failure.t.err
359 359 @@ -1,5 +1,5 @@
360 360 $ echo babar
361 361 - rataxes
362 362 + babar
363 363 This is a noop statement so that
364 364 this test is still more bytes than success.
365 365 pad pad pad pad............................................................
366 366 ]]> </failure>
367 367 </testcase>
368 368 </testsuite>
369 369
370 370 $ cat .testtimes
371 371 test-failure-unicode.t * (glob)
372 372 test-failure.t * (glob)
373 373 test-success.t * (glob)
374 374
375 375 $ rt --list-tests
376 376 test-failure-unicode.t
377 377 test-failure.t
378 378 test-success.t
379 379
380 380 $ rt --list-tests --json
381 381 test-failure-unicode.t
382 382 test-failure.t
383 383 test-success.t
384 384 $ cat report.json
385 385 testreport ={
386 386 "test-failure-unicode.t": {
387 387 "result": "success"
388 388 },
389 389 "test-failure.t": {
390 390 "result": "success"
391 391 },
392 392 "test-success.t": {
393 393 "result": "success"
394 394 }
395 395 } (no-eol)
396 396
397 397 $ rt --list-tests --xunit=xunit.xml
398 398 test-failure-unicode.t
399 399 test-failure.t
400 400 test-success.t
401 401 $ cat xunit.xml
402 402 <?xml version="1.0" encoding="utf-8"?>
403 403 <testsuite errors="0" failures="0" name="run-tests" skipped="0" tests="0">
404 404 <testcase name="test-failure-unicode.t"/>
405 405 <testcase name="test-failure.t"/>
406 406 <testcase name="test-success.t"/>
407 407 </testsuite>
408 408
409 409 $ rt --list-tests test-failure* --json --xunit=xunit.xml --outputdir output
410 410 test-failure-unicode.t
411 411 test-failure.t
412 412 $ cat output/report.json
413 413 testreport ={
414 414 "test-failure-unicode.t": {
415 415 "result": "success"
416 416 },
417 417 "test-failure.t": {
418 418 "result": "success"
419 419 }
420 420 } (no-eol)
421 421 $ cat xunit.xml
422 422 <?xml version="1.0" encoding="utf-8"?>
423 423 <testsuite errors="0" failures="0" name="run-tests" skipped="0" tests="0">
424 424 <testcase name="test-failure-unicode.t"/>
425 425 <testcase name="test-failure.t"/>
426 426 </testsuite>
427 427
428 428 $ rm test-failure-unicode.t
429 429
430 430 test for --retest
431 431 ====================
432 432
433 433 $ rt --retest
434 434
435 435 --- $TESTTMP/test-failure.t
436 436 +++ $TESTTMP/test-failure.t.err
437 437 @@ -1,5 +1,5 @@
438 438 $ echo babar
439 439 - rataxes
440 440 + babar
441 441 This is a noop statement so that
442 442 this test is still more bytes than success.
443 443 pad pad pad pad............................................................
444 444
445 445 ERROR: test-failure.t output changed
446 446 !
447 447 Failed test-failure.t: output changed
448 448 # Ran 2 tests, 1 skipped, 1 failed.
449 449 python hash seed: * (glob)
450 450 [1]
451 451
452 452 --retest works with --outputdir
453 453 $ rm -r output
454 454 $ mkdir output
455 455 $ mv test-failure.t.err output
456 456 $ rt --retest --outputdir output
457 457
458 458 --- $TESTTMP/test-failure.t
459 459 +++ $TESTTMP/output/test-failure.t.err
460 460 @@ -1,5 +1,5 @@
461 461 $ echo babar
462 462 - rataxes
463 463 + babar
464 464 This is a noop statement so that
465 465 this test is still more bytes than success.
466 466 pad pad pad pad............................................................
467 467
468 468 ERROR: test-failure.t output changed
469 469 !
470 470 Failed test-failure.t: output changed
471 471 # Ran 2 tests, 1 skipped, 1 failed.
472 472 python hash seed: * (glob)
473 473 [1]
474 474
475 475 Selecting Tests To Run
476 476 ======================
477 477
478 478 successful
479 479
480 480 $ rt test-success.t
481 481 .
482 482 # Ran 1 tests, 0 skipped, 0 failed.
483 483
484 484 success w/ keyword
485 485 $ rt -k xyzzy
486 486 .
487 487 # Ran 2 tests, 1 skipped, 0 failed.
488 488
489 489 failed
490 490
491 491 $ rt test-failure.t
492 492
493 493 --- $TESTTMP/test-failure.t
494 494 +++ $TESTTMP/test-failure.t.err
495 495 @@ -1,5 +1,5 @@
496 496 $ echo babar
497 497 - rataxes
498 498 + babar
499 499 This is a noop statement so that
500 500 this test is still more bytes than success.
501 501 pad pad pad pad............................................................
502 502
503 503 ERROR: test-failure.t output changed
504 504 !
505 505 Failed test-failure.t: output changed
506 506 # Ran 1 tests, 0 skipped, 1 failed.
507 507 python hash seed: * (glob)
508 508 [1]
509 509
510 510 failure w/ keyword
511 511 $ rt -k rataxes
512 512
513 513 --- $TESTTMP/test-failure.t
514 514 +++ $TESTTMP/test-failure.t.err
515 515 @@ -1,5 +1,5 @@
516 516 $ echo babar
517 517 - rataxes
518 518 + babar
519 519 This is a noop statement so that
520 520 this test is still more bytes than success.
521 521 pad pad pad pad............................................................
522 522
523 523 ERROR: test-failure.t output changed
524 524 !
525 525 Failed test-failure.t: output changed
526 526 # Ran 2 tests, 1 skipped, 1 failed.
527 527 python hash seed: * (glob)
528 528 [1]
529 529
530 530 Verify that when a process fails to start we show a useful message
531 531 ==================================================================
532 532
533 533 $ cat > test-serve-fail.t <<EOF
534 534 > $ echo 'abort: child process failed to start blah'
535 535 > EOF
536 536 $ rt test-serve-fail.t
537 537
538 538 ERROR: test-serve-fail.t output changed
539 539 !
540 540 Failed test-serve-fail.t: server failed to start (HGPORT=*) (glob)
541 541 # Ran 1 tests, 0 skipped, 1 failed.
542 542 python hash seed: * (glob)
543 543 [1]
544 544 $ rm test-serve-fail.t
545 545
546 546 Verify that we can try other ports
547 547 ===================================
548 548 $ hg init inuse
549 549 $ hg serve -R inuse -p $HGPORT -d --pid-file=blocks.pid
550 550 $ cat blocks.pid >> $DAEMON_PIDS
551 551 $ cat > test-serve-inuse.t <<EOF
552 552 > $ hg serve -R `pwd`/inuse -p \$HGPORT -d --pid-file=hg.pid
553 553 > $ cat hg.pid >> \$DAEMON_PIDS
554 554 > EOF
555 555 $ rt test-serve-inuse.t
556 556 .
557 557 # Ran 1 tests, 0 skipped, 0 failed.
558 558 $ rm test-serve-inuse.t
559 559 $ killdaemons.py $DAEMON_PIDS
560 560 $ rm $DAEMON_PIDS
561 561
562 562 Running In Debug Mode
563 563 ======================
564 564
565 565 $ rt --debug 2>&1 | grep -v pwd
566 566 + echo *SALT* 0 0 (glob)
567 567 *SALT* 0 0 (glob)
568 568 + echo babar
569 569 babar
570 570 + echo *SALT* 10 0 (glob)
571 571 *SALT* 10 0 (glob)
572 572 *+ echo *SALT* 0 0 (glob)
573 573 *SALT* 0 0 (glob)
574 574 + echo babar
575 575 babar
576 576 + echo *SALT* 2 0 (glob)
577 577 *SALT* 2 0 (glob)
578 578 + echo xyzzy
579 579 xyzzy
580 580 + echo *SALT* 9 0 (glob)
581 581 *SALT* 9 0 (glob)
582 582 + printf *abc\ndef\nxyz\n* (glob)
583 583 abc
584 584 def
585 585 xyz
586 586 + echo *SALT* 15 0 (glob)
587 587 *SALT* 15 0 (glob)
588 588 + printf *zyx\nwvu\ntsr\n* (glob)
589 589 zyx
590 590 wvu
591 591 tsr
592 592 + echo *SALT* 22 0 (glob)
593 593 *SALT* 22 0 (glob)
594 594 .
595 595 # Ran 2 tests, 0 skipped, 0 failed.
596 596
597 597 Parallel runs
598 598 ==============
599 599
600 600 (duplicate the failing test to get predictable output)
601 601 $ cp test-failure.t test-failure-copy.t
602 602
603 603 $ rt --jobs 2 test-failure*.t -n
604 604 !!
605 605 Failed test-failure*.t: output changed (glob)
606 606 Failed test-failure*.t: output changed (glob)
607 607 # Ran 2 tests, 0 skipped, 2 failed.
608 608 python hash seed: * (glob)
609 609 [1]
610 610
611 611 failures in parallel with --first should only print one failure
612 >>> f = open('test-nothing.t', 'w')
613 >>> f.write('foo\n' * 1024) and None
614 >>> f.write(' $ sleep 1') and None
615 $ rt --jobs 2 --first
612 $ rt --jobs 2 --first test-failure*.t
616 613
617 614 --- $TESTTMP/test-failure*.t (glob)
618 615 +++ $TESTTMP/test-failure*.t.err (glob)
619 616 @@ -1,5 +1,5 @@
620 617 $ echo babar
621 618 - rataxes
622 619 + babar
623 620 This is a noop statement so that
624 621 this test is still more bytes than success.
625 622 pad pad pad pad............................................................
626 623
627 624 Failed test-failure*.t: output changed (glob)
628 Failed test-nothing.t: output changed
625 Failed test-failure*.t: output changed (glob)
629 626 # Ran 2 tests, 0 skipped, 2 failed.
630 627 python hash seed: * (glob)
631 628 [1]
632 629
633 630
634 631 (delete the duplicated test file)
635 $ rm test-failure-copy.t test-nothing.t
632 $ rm test-failure-copy.t
636 633
637 634
638 635 Interactive run
639 636 ===============
640 637
641 638 (backup the failing test)
642 639 $ cp test-failure.t backup
643 640
644 641 Refuse the fix
645 642
646 643 $ echo 'n' | rt -i
647 644
648 645 --- $TESTTMP/test-failure.t
649 646 +++ $TESTTMP/test-failure.t.err
650 647 @@ -1,5 +1,5 @@
651 648 $ echo babar
652 649 - rataxes
653 650 + babar
654 651 This is a noop statement so that
655 652 this test is still more bytes than success.
656 653 pad pad pad pad............................................................
657 654 Accept this change? [n]
658 655 ERROR: test-failure.t output changed
659 656 !.
660 657 Failed test-failure.t: output changed
661 658 # Ran 2 tests, 0 skipped, 1 failed.
662 659 python hash seed: * (glob)
663 660 [1]
664 661
665 662 $ cat test-failure.t
666 663 $ echo babar
667 664 rataxes
668 665 This is a noop statement so that
669 666 this test is still more bytes than success.
670 667 pad pad pad pad............................................................
671 668 pad pad pad pad............................................................
672 669 pad pad pad pad............................................................
673 670 pad pad pad pad............................................................
674 671 pad pad pad pad............................................................
675 672 pad pad pad pad............................................................
676 673
677 674 Interactive with custom view
678 675
679 676 $ echo 'n' | rt -i --view echo
680 677 $TESTTMP/test-failure.t $TESTTMP/test-failure.t.err (glob)
681 678 Accept this change? [n]* (glob)
682 679 ERROR: test-failure.t output changed
683 680 !.
684 681 Failed test-failure.t: output changed
685 682 # Ran 2 tests, 0 skipped, 1 failed.
686 683 python hash seed: * (glob)
687 684 [1]
688 685
689 686 View the fix
690 687
691 688 $ echo 'y' | rt --view echo
692 689 $TESTTMP/test-failure.t $TESTTMP/test-failure.t.err (glob)
693 690
694 691 ERROR: test-failure.t output changed
695 692 !.
696 693 Failed test-failure.t: output changed
697 694 # Ran 2 tests, 0 skipped, 1 failed.
698 695 python hash seed: * (glob)
699 696 [1]
700 697
701 698 Accept the fix
702 699
703 700 $ echo " $ echo 'saved backup bundle to \$TESTTMP/foo.hg'" >> test-failure.t
704 701 $ echo " saved backup bundle to \$TESTTMP/foo.hg" >> test-failure.t
705 702 $ echo " $ echo 'saved backup bundle to \$TESTTMP/foo.hg'" >> test-failure.t
706 703 $ echo " saved backup bundle to \$TESTTMP/foo.hg (glob)" >> test-failure.t
707 704 $ echo " $ echo 'saved backup bundle to \$TESTTMP/foo.hg'" >> test-failure.t
708 705 $ echo " saved backup bundle to \$TESTTMP/*.hg (glob)" >> test-failure.t
709 706 $ echo 'y' | rt -i 2>&1
710 707
711 708 --- $TESTTMP/test-failure.t
712 709 +++ $TESTTMP/test-failure.t.err
713 710 @@ -1,5 +1,5 @@
714 711 $ echo babar
715 712 - rataxes
716 713 + babar
717 714 This is a noop statement so that
718 715 this test is still more bytes than success.
719 716 pad pad pad pad............................................................
720 717 @@ -9,7 +9,7 @@
721 718 pad pad pad pad............................................................
722 719 pad pad pad pad............................................................
723 720 $ echo 'saved backup bundle to $TESTTMP/foo.hg'
724 721 - saved backup bundle to $TESTTMP/foo.hg
725 722 + saved backup bundle to $TESTTMP/foo.hg* (glob)
726 723 $ echo 'saved backup bundle to $TESTTMP/foo.hg'
727 724 saved backup bundle to $TESTTMP/foo.hg* (glob)
728 725 $ echo 'saved backup bundle to $TESTTMP/foo.hg'
729 726 Accept this change? [n] ..
730 727 # Ran 2 tests, 0 skipped, 0 failed.
731 728
732 729 $ sed -e 's,(glob)$,&<,g' test-failure.t
733 730 $ echo babar
734 731 babar
735 732 This is a noop statement so that
736 733 this test is still more bytes than success.
737 734 pad pad pad pad............................................................
738 735 pad pad pad pad............................................................
739 736 pad pad pad pad............................................................
740 737 pad pad pad pad............................................................
741 738 pad pad pad pad............................................................
742 739 pad pad pad pad............................................................
743 740 $ echo 'saved backup bundle to $TESTTMP/foo.hg'
744 741 saved backup bundle to $TESTTMP/foo.hg (glob)<
745 742 $ echo 'saved backup bundle to $TESTTMP/foo.hg'
746 743 saved backup bundle to $TESTTMP/foo.hg (glob)<
747 744 $ echo 'saved backup bundle to $TESTTMP/foo.hg'
748 745 saved backup bundle to $TESTTMP/*.hg (glob)<
749 746
750 747 Race condition - test file was modified when test is running
751 748
752 749 $ TESTRACEDIR=`pwd`
753 750 $ export TESTRACEDIR
754 751 $ cat > test-race.t <<EOF
755 752 > $ echo 1
756 753 > $ echo "# a new line" >> $TESTRACEDIR/test-race.t
757 754 > EOF
758 755
759 756 $ rt -i test-race.t
760 757
761 758 --- $TESTTMP/test-race.t
762 759 +++ $TESTTMP/test-race.t.err
763 760 @@ -1,2 +1,3 @@
764 761 $ echo 1
765 762 + 1
766 763 $ echo "# a new line" >> $TESTTMP/test-race.t
767 764 Reference output has changed (run again to prompt changes)
768 765 ERROR: test-race.t output changed
769 766 !
770 767 Failed test-race.t: output changed
771 768 # Ran 1 tests, 0 skipped, 1 failed.
772 769 python hash seed: * (glob)
773 770 [1]
774 771
775 772 $ rm test-race.t
776 773
777 774 When "#testcases" is used in .t files
778 775
779 776 $ cat >> test-cases.t <<EOF
780 777 > #testcases a b
781 778 > #if a
782 779 > $ echo 1
783 780 > #endif
784 781 > #if b
785 782 > $ echo 2
786 783 > #endif
787 784 > EOF
788 785
789 786 $ cat <<EOF | rt -i test-cases.t 2>&1
790 787 > y
791 788 > y
792 789 > EOF
793 790
794 791 --- $TESTTMP/test-cases.t
795 792 +++ $TESTTMP/test-cases.t.a.err
796 793 @@ -1,6 +1,7 @@
797 794 #testcases a b
798 795 #if a
799 796 $ echo 1
800 797 + 1
801 798 #endif
802 799 #if b
803 800 $ echo 2
804 801 Accept this change? [n] .
805 802 --- $TESTTMP/test-cases.t
806 803 +++ $TESTTMP/test-cases.t.b.err
807 804 @@ -5,4 +5,5 @@
808 805 #endif
809 806 #if b
810 807 $ echo 2
811 808 + 2
812 809 #endif
813 810 Accept this change? [n] .
814 811 # Ran 2 tests, 0 skipped, 0 failed.
815 812
816 813 $ cat test-cases.t
817 814 #testcases a b
818 815 #if a
819 816 $ echo 1
820 817 1
821 818 #endif
822 819 #if b
823 820 $ echo 2
824 821 2
825 822 #endif
826 823
827 824 $ cat >> test-cases.t <<'EOF'
828 825 > #if a
829 826 > $ NAME=A
830 827 > #else
831 828 > $ NAME=B
832 829 > #endif
833 830 > $ echo $NAME
834 831 > A (a !)
835 832 > B (b !)
836 833 > EOF
837 834 $ rt test-cases.t
838 835 ..
839 836 # Ran 2 tests, 0 skipped, 0 failed.
840 837
841 838 $ rm test-cases.t
842 839
843 840 (reinstall)
844 841 $ mv backup test-failure.t
845 842
846 843 No Diff
847 844 ===============
848 845
849 846 $ rt --nodiff
850 847 !.
851 848 Failed test-failure.t: output changed
852 849 # Ran 2 tests, 0 skipped, 1 failed.
853 850 python hash seed: * (glob)
854 851 [1]
855 852
856 853 test --tmpdir support
857 854 $ rt --tmpdir=$TESTTMP/keep test-success.t
858 855
859 856 Keeping testtmp dir: $TESTTMP/keep/child1/test-success.t (glob)
860 857 Keeping threadtmp dir: $TESTTMP/keep/child1 (glob)
861 858 .
862 859 # Ran 1 tests, 0 skipped, 0 failed.
863 860
864 861 timeouts
865 862 ========
866 863 $ cat > test-timeout.t <<EOF
867 864 > $ sleep 2
868 865 > $ echo pass
869 866 > pass
870 867 > EOF
871 868 > echo '#require slow' > test-slow-timeout.t
872 869 > cat test-timeout.t >> test-slow-timeout.t
873 870 $ rt --timeout=1 --slowtimeout=3 test-timeout.t test-slow-timeout.t
874 871 st
875 872 Skipped test-slow-timeout.t: missing feature: allow slow tests (use --allow-slow-tests)
876 873 Failed test-timeout.t: timed out
877 874 # Ran 1 tests, 1 skipped, 1 failed.
878 875 python hash seed: * (glob)
879 876 [1]
880 877 $ rt --timeout=1 --slowtimeout=3 \
881 878 > test-timeout.t test-slow-timeout.t --allow-slow-tests
882 879 .t
883 880 Failed test-timeout.t: timed out
884 881 # Ran 2 tests, 0 skipped, 1 failed.
885 882 python hash seed: * (glob)
886 883 [1]
887 884 $ rm test-timeout.t test-slow-timeout.t
888 885
889 886 test for --time
890 887 ==================
891 888
892 889 $ rt test-success.t --time
893 890 .
894 891 # Ran 1 tests, 0 skipped, 0 failed.
895 892 # Producing time report
896 893 start end cuser csys real Test
897 894 \s*[\d\.]{5} \s*[\d\.]{5} \s*[\d\.]{5} \s*[\d\.]{5} \s*[\d\.]{5} test-success.t (re)
898 895
899 896 test for --time with --job enabled
900 897 ====================================
901 898
902 899 $ rt test-success.t --time --jobs 2
903 900 .
904 901 # Ran 1 tests, 0 skipped, 0 failed.
905 902 # Producing time report
906 903 start end cuser csys real Test
907 904 \s*[\d\.]{5} \s*[\d\.]{5} \s*[\d\.]{5} \s*[\d\.]{5} \s*[\d\.]{5} test-success.t (re)
908 905
909 906 Skips
910 907 ================
911 908 $ cat > test-skip.t <<EOF
912 909 > $ echo xyzzy
913 910 > #require false
914 911 > EOF
915 912 $ rt --nodiff
916 913 !.s
917 914 Skipped test-skip.t: missing feature: nail clipper
918 915 Failed test-failure.t: output changed
919 916 # Ran 2 tests, 1 skipped, 1 failed.
920 917 python hash seed: * (glob)
921 918 [1]
922 919
923 920 $ rt --keyword xyzzy
924 921 .s
925 922 Skipped test-skip.t: missing feature: nail clipper
926 923 # Ran 2 tests, 2 skipped, 0 failed.
927 924
928 925 Skips with xml
929 926 $ rt --keyword xyzzy \
930 927 > --xunit=xunit.xml
931 928 .s
932 929 Skipped test-skip.t: missing feature: nail clipper
933 930 # Ran 2 tests, 2 skipped, 0 failed.
934 931 $ cat xunit.xml
935 932 <?xml version="1.0" encoding="utf-8"?>
936 933 <testsuite errors="0" failures="0" name="run-tests" skipped="2" tests="2">
937 934 <testcase name="test-success.t" time="*"/> (glob)
938 935 <testcase name="test-skip.t">
939 936 <skipped>
940 937 <![CDATA[missing feature: nail clipper]]> </skipped>
941 938 </testcase>
942 939 </testsuite>
943 940
944 941 Missing skips or blacklisted skips don't count as executed:
945 942 $ echo test-failure.t > blacklist
946 943 $ rt --blacklist=blacklist --json\
947 944 > test-failure.t test-bogus.t
948 945 ss
949 946 Skipped test-bogus.t: Doesn't exist
950 947 Skipped test-failure.t: blacklisted
951 948 # Ran 0 tests, 2 skipped, 0 failed.
952 949 $ cat report.json
953 950 testreport ={
954 951 "test-bogus.t": {
955 952 "result": "skip"
956 953 },
957 954 "test-failure.t": {
958 955 "result": "skip"
959 956 }
960 957 } (no-eol)
961 958
962 959 Whitelist trumps blacklist
963 960 $ echo test-failure.t > whitelist
964 961 $ rt --blacklist=blacklist --whitelist=whitelist --json\
965 962 > test-failure.t test-bogus.t
966 963 s
967 964 --- $TESTTMP/test-failure.t
968 965 +++ $TESTTMP/test-failure.t.err
969 966 @@ -1,5 +1,5 @@
970 967 $ echo babar
971 968 - rataxes
972 969 + babar
973 970 This is a noop statement so that
974 971 this test is still more bytes than success.
975 972 pad pad pad pad............................................................
976 973
977 974 ERROR: test-failure.t output changed
978 975 !
979 976 Skipped test-bogus.t: Doesn't exist
980 977 Failed test-failure.t: output changed
981 978 # Ran 1 tests, 1 skipped, 1 failed.
982 979 python hash seed: * (glob)
983 980 [1]
984 981
985 982 Ensure that --test-list causes only the tests listed in that file to
986 983 be executed.
987 984 $ echo test-success.t >> onlytest
988 985 $ rt --test-list=onlytest
989 986 .
990 987 # Ran 1 tests, 0 skipped, 0 failed.
991 988 $ echo test-bogus.t >> anothertest
992 989 $ rt --test-list=onlytest --test-list=anothertest
993 990 s.
994 991 Skipped test-bogus.t: Doesn't exist
995 992 # Ran 1 tests, 1 skipped, 0 failed.
996 993 $ rm onlytest anothertest
997 994
998 995 test for --json
999 996 ==================
1000 997
1001 998 $ rt --json
1002 999
1003 1000 --- $TESTTMP/test-failure.t
1004 1001 +++ $TESTTMP/test-failure.t.err
1005 1002 @@ -1,5 +1,5 @@
1006 1003 $ echo babar
1007 1004 - rataxes
1008 1005 + babar
1009 1006 This is a noop statement so that
1010 1007 this test is still more bytes than success.
1011 1008 pad pad pad pad............................................................
1012 1009
1013 1010 ERROR: test-failure.t output changed
1014 1011 !.s
1015 1012 Skipped test-skip.t: missing feature: nail clipper
1016 1013 Failed test-failure.t: output changed
1017 1014 # Ran 2 tests, 1 skipped, 1 failed.
1018 1015 python hash seed: * (glob)
1019 1016 [1]
1020 1017
1021 1018 $ cat report.json
1022 1019 testreport ={
1023 1020 "test-failure.t": [\{] (re)
1024 1021 "csys": "\s*[\d\.]{4,5}", ? (re)
1025 1022 "cuser": "\s*[\d\.]{4,5}", ? (re)
1026 1023 "diff": "---.+\+\+\+.+", ? (re)
1027 1024 "end": "\s*[\d\.]{4,5}", ? (re)
1028 1025 "result": "failure", ? (re)
1029 1026 "start": "\s*[\d\.]{4,5}", ? (re)
1030 1027 "time": "\s*[\d\.]{4,5}" (re)
1031 1028 }, ? (re)
1032 1029 "test-skip.t": {
1033 1030 "csys": "\s*[\d\.]{4,5}", ? (re)
1034 1031 "cuser": "\s*[\d\.]{4,5}", ? (re)
1035 1032 "diff": "", ? (re)
1036 1033 "end": "\s*[\d\.]{4,5}", ? (re)
1037 1034 "result": "skip", ? (re)
1038 1035 "start": "\s*[\d\.]{4,5}", ? (re)
1039 1036 "time": "\s*[\d\.]{4,5}" (re)
1040 1037 }, ? (re)
1041 1038 "test-success.t": [\{] (re)
1042 1039 "csys": "\s*[\d\.]{4,5}", ? (re)
1043 1040 "cuser": "\s*[\d\.]{4,5}", ? (re)
1044 1041 "diff": "", ? (re)
1045 1042 "end": "\s*[\d\.]{4,5}", ? (re)
1046 1043 "result": "success", ? (re)
1047 1044 "start": "\s*[\d\.]{4,5}", ? (re)
1048 1045 "time": "\s*[\d\.]{4,5}" (re)
1049 1046 }
1050 1047 } (no-eol)
1051 1048 --json with --outputdir
1052 1049
1053 1050 $ rm report.json
1054 1051 $ rm -r output
1055 1052 $ mkdir output
1056 1053 $ rt --json --outputdir output
1057 1054
1058 1055 --- $TESTTMP/test-failure.t
1059 1056 +++ $TESTTMP/output/test-failure.t.err
1060 1057 @@ -1,5 +1,5 @@
1061 1058 $ echo babar
1062 1059 - rataxes
1063 1060 + babar
1064 1061 This is a noop statement so that
1065 1062 this test is still more bytes than success.
1066 1063 pad pad pad pad............................................................
1067 1064
1068 1065 ERROR: test-failure.t output changed
1069 1066 !.s
1070 1067 Skipped test-skip.t: missing feature: nail clipper
1071 1068 Failed test-failure.t: output changed
1072 1069 # Ran 2 tests, 1 skipped, 1 failed.
1073 1070 python hash seed: * (glob)
1074 1071 [1]
1075 1072 $ f report.json
1076 1073 report.json: file not found
1077 1074 $ cat output/report.json
1078 1075 testreport ={
1079 1076 "test-failure.t": [\{] (re)
1080 1077 "csys": "\s*[\d\.]{4,5}", ? (re)
1081 1078 "cuser": "\s*[\d\.]{4,5}", ? (re)
1082 1079 "diff": "---.+\+\+\+.+", ? (re)
1083 1080 "end": "\s*[\d\.]{4,5}", ? (re)
1084 1081 "result": "failure", ? (re)
1085 1082 "start": "\s*[\d\.]{4,5}", ? (re)
1086 1083 "time": "\s*[\d\.]{4,5}" (re)
1087 1084 }, ? (re)
1088 1085 "test-skip.t": {
1089 1086 "csys": "\s*[\d\.]{4,5}", ? (re)
1090 1087 "cuser": "\s*[\d\.]{4,5}", ? (re)
1091 1088 "diff": "", ? (re)
1092 1089 "end": "\s*[\d\.]{4,5}", ? (re)
1093 1090 "result": "skip", ? (re)
1094 1091 "start": "\s*[\d\.]{4,5}", ? (re)
1095 1092 "time": "\s*[\d\.]{4,5}" (re)
1096 1093 }, ? (re)
1097 1094 "test-success.t": [\{] (re)
1098 1095 "csys": "\s*[\d\.]{4,5}", ? (re)
1099 1096 "cuser": "\s*[\d\.]{4,5}", ? (re)
1100 1097 "diff": "", ? (re)
1101 1098 "end": "\s*[\d\.]{4,5}", ? (re)
1102 1099 "result": "success", ? (re)
1103 1100 "start": "\s*[\d\.]{4,5}", ? (re)
1104 1101 "time": "\s*[\d\.]{4,5}" (re)
1105 1102 }
1106 1103 } (no-eol)
1107 1104 $ ls -a output
1108 1105 .
1109 1106 ..
1110 1107 .testtimes
1111 1108 report.json
1112 1109 test-failure.t.err
1113 1110
1114 1111 Test that failed test accepted through interactive are properly reported:
1115 1112
1116 1113 $ cp test-failure.t backup
1117 1114 $ echo y | rt --json -i
1118 1115
1119 1116 --- $TESTTMP/test-failure.t
1120 1117 +++ $TESTTMP/test-failure.t.err
1121 1118 @@ -1,5 +1,5 @@
1122 1119 $ echo babar
1123 1120 - rataxes
1124 1121 + babar
1125 1122 This is a noop statement so that
1126 1123 this test is still more bytes than success.
1127 1124 pad pad pad pad............................................................
1128 1125 Accept this change? [n] ..s
1129 1126 Skipped test-skip.t: missing feature: nail clipper
1130 1127 # Ran 2 tests, 1 skipped, 0 failed.
1131 1128
1132 1129 $ cat report.json
1133 1130 testreport ={
1134 1131 "test-failure.t": [\{] (re)
1135 1132 "csys": "\s*[\d\.]{4,5}", ? (re)
1136 1133 "cuser": "\s*[\d\.]{4,5}", ? (re)
1137 1134 "diff": "", ? (re)
1138 1135 "end": "\s*[\d\.]{4,5}", ? (re)
1139 1136 "result": "success", ? (re)
1140 1137 "start": "\s*[\d\.]{4,5}", ? (re)
1141 1138 "time": "\s*[\d\.]{4,5}" (re)
1142 1139 }, ? (re)
1143 1140 "test-skip.t": {
1144 1141 "csys": "\s*[\d\.]{4,5}", ? (re)
1145 1142 "cuser": "\s*[\d\.]{4,5}", ? (re)
1146 1143 "diff": "", ? (re)
1147 1144 "end": "\s*[\d\.]{4,5}", ? (re)
1148 1145 "result": "skip", ? (re)
1149 1146 "start": "\s*[\d\.]{4,5}", ? (re)
1150 1147 "time": "\s*[\d\.]{4,5}" (re)
1151 1148 }, ? (re)
1152 1149 "test-success.t": [\{] (re)
1153 1150 "csys": "\s*[\d\.]{4,5}", ? (re)
1154 1151 "cuser": "\s*[\d\.]{4,5}", ? (re)
1155 1152 "diff": "", ? (re)
1156 1153 "end": "\s*[\d\.]{4,5}", ? (re)
1157 1154 "result": "success", ? (re)
1158 1155 "start": "\s*[\d\.]{4,5}", ? (re)
1159 1156 "time": "\s*[\d\.]{4,5}" (re)
1160 1157 }
1161 1158 } (no-eol)
1162 1159 $ mv backup test-failure.t
1163 1160
1164 1161 backslash on end of line with glob matching is handled properly
1165 1162
1166 1163 $ cat > test-glob-backslash.t << EOF
1167 1164 > $ echo 'foo bar \\'
1168 1165 > foo * \ (glob)
1169 1166 > EOF
1170 1167
1171 1168 $ rt test-glob-backslash.t
1172 1169 .
1173 1170 # Ran 1 tests, 0 skipped, 0 failed.
1174 1171
1175 1172 $ rm -f test-glob-backslash.t
1176 1173
1177 1174 Test globbing of local IP addresses
1178 1175 $ echo 172.16.18.1
1179 1176 $LOCALIP (glob)
1180 1177 $ echo dead:beef::1
1181 1178 $LOCALIP (glob)
1182 1179
1183 1180 Test reusability for third party tools
1184 1181 ======================================
1185 1182
1186 1183 $ mkdir "$TESTTMP"/anothertests
1187 1184 $ cd "$TESTTMP"/anothertests
1188 1185
1189 1186 test that `run-tests.py` can execute hghave, even if it runs not in
1190 1187 Mercurial source tree.
1191 1188
1192 1189 $ cat > test-hghave.t <<EOF
1193 1190 > #require true
1194 1191 > $ echo foo
1195 1192 > foo
1196 1193 > EOF
1197 1194 $ rt test-hghave.t
1198 1195 .
1199 1196 # Ran 1 tests, 0 skipped, 0 failed.
1200 1197
1201 1198 test that RUNTESTDIR refers the directory, in which `run-tests.py` now
1202 1199 running is placed.
1203 1200
1204 1201 $ cat > test-runtestdir.t <<EOF
1205 1202 > - $TESTDIR, in which test-run-tests.t is placed
1206 1203 > - \$TESTDIR, in which test-runtestdir.t is placed (expanded at runtime)
1207 1204 > - \$RUNTESTDIR, in which run-tests.py is placed (expanded at runtime)
1208 1205 >
1209 1206 > #if windows
1210 1207 > $ test "\$TESTDIR" = "$TESTTMP\anothertests"
1211 1208 > #else
1212 1209 > $ test "\$TESTDIR" = "$TESTTMP"/anothertests
1213 1210 > #endif
1214 1211 > $ test "\$RUNTESTDIR" = "$TESTDIR"
1215 1212 > $ head -n 3 "\$RUNTESTDIR"/../contrib/check-code.py | sed 's@.!.*python@#!USRBINENVPY@'
1216 1213 > #!USRBINENVPY
1217 1214 > #
1218 1215 > # check-code - a style and portability checker for Mercurial
1219 1216 > EOF
1220 1217 $ rt test-runtestdir.t
1221 1218 .
1222 1219 # Ran 1 tests, 0 skipped, 0 failed.
1223 1220
1224 1221 #if execbit
1225 1222
1226 1223 test that TESTDIR is referred in PATH
1227 1224
1228 1225 $ cat > custom-command.sh <<EOF
1229 1226 > #!/bin/sh
1230 1227 > echo "hello world"
1231 1228 > EOF
1232 1229 $ chmod +x custom-command.sh
1233 1230 $ cat > test-testdir-path.t <<EOF
1234 1231 > $ custom-command.sh
1235 1232 > hello world
1236 1233 > EOF
1237 1234 $ rt test-testdir-path.t
1238 1235 .
1239 1236 # Ran 1 tests, 0 skipped, 0 failed.
1240 1237
1241 1238 #endif
1242 1239
1243 1240 test support for --allow-slow-tests
1244 1241 $ cat > test-very-slow-test.t <<EOF
1245 1242 > #require slow
1246 1243 > $ echo pass
1247 1244 > pass
1248 1245 > EOF
1249 1246 $ rt test-very-slow-test.t
1250 1247 s
1251 1248 Skipped test-very-slow-test.t: missing feature: allow slow tests (use --allow-slow-tests)
1252 1249 # Ran 0 tests, 1 skipped, 0 failed.
1253 1250 $ rt $HGTEST_RUN_TESTS_PURE --allow-slow-tests test-very-slow-test.t
1254 1251 .
1255 1252 # Ran 1 tests, 0 skipped, 0 failed.
1256 1253
1257 1254 support for running a test outside the current directory
1258 1255 $ mkdir nonlocal
1259 1256 $ cat > nonlocal/test-is-not-here.t << EOF
1260 1257 > $ echo pass
1261 1258 > pass
1262 1259 > EOF
1263 1260 $ rt nonlocal/test-is-not-here.t
1264 1261 .
1265 1262 # Ran 1 tests, 0 skipped, 0 failed.
1266 1263
1267 1264 support for bisecting failed tests automatically
1268 1265 $ hg init bisect
1269 1266 $ cd bisect
1270 1267 $ cat >> test-bisect.t <<EOF
1271 1268 > $ echo pass
1272 1269 > pass
1273 1270 > EOF
1274 1271 $ hg add test-bisect.t
1275 1272 $ hg ci -m 'good'
1276 1273 $ cat >> test-bisect.t <<EOF
1277 1274 > $ echo pass
1278 1275 > fail
1279 1276 > EOF
1280 1277 $ hg ci -m 'bad'
1281 1278 $ rt --known-good-rev=0 test-bisect.t
1282 1279
1283 1280 --- $TESTTMP/anothertests/bisect/test-bisect.t
1284 1281 +++ $TESTTMP/anothertests/bisect/test-bisect.t.err
1285 1282 @@ -1,4 +1,4 @@
1286 1283 $ echo pass
1287 1284 pass
1288 1285 $ echo pass
1289 1286 - fail
1290 1287 + pass
1291 1288
1292 1289 ERROR: test-bisect.t output changed
1293 1290 !
1294 1291 Failed test-bisect.t: output changed
1295 1292 test-bisect.t broken by 72cbf122d116 (bad)
1296 1293 # Ran 1 tests, 0 skipped, 1 failed.
1297 1294 python hash seed: * (glob)
1298 1295 [1]
1299 1296
1300 1297 $ cd ..
1301 1298
1302 1299 support bisecting a separate repo
1303 1300
1304 1301 $ hg init bisect-dependent
1305 1302 $ cd bisect-dependent
1306 1303 $ cat > test-bisect-dependent.t <<EOF
1307 1304 > $ tail -1 \$TESTDIR/../bisect/test-bisect.t
1308 1305 > pass
1309 1306 > EOF
1310 1307 $ hg commit -Am dependent test-bisect-dependent.t
1311 1308
1312 1309 $ rt --known-good-rev=0 test-bisect-dependent.t
1313 1310
1314 1311 --- $TESTTMP/anothertests/bisect-dependent/test-bisect-dependent.t
1315 1312 +++ $TESTTMP/anothertests/bisect-dependent/test-bisect-dependent.t.err
1316 1313 @@ -1,2 +1,2 @@
1317 1314 $ tail -1 $TESTDIR/../bisect/test-bisect.t
1318 1315 - pass
1319 1316 + fail
1320 1317
1321 1318 ERROR: test-bisect-dependent.t output changed
1322 1319 !
1323 1320 Failed test-bisect-dependent.t: output changed
1324 1321 Failed to identify failure point for test-bisect-dependent.t
1325 1322 # Ran 1 tests, 0 skipped, 1 failed.
1326 1323 python hash seed: * (glob)
1327 1324 [1]
1328 1325
1329 1326 $ rt --bisect-repo=../test-bisect test-bisect-dependent.t
1330 1327 Usage: run-tests.py [options] [tests]
1331 1328
1332 1329 run-tests.py: error: --bisect-repo cannot be used without --known-good-rev
1333 1330 [2]
1334 1331
1335 1332 $ rt --known-good-rev=0 --bisect-repo=../bisect test-bisect-dependent.t
1336 1333
1337 1334 --- $TESTTMP/anothertests/bisect-dependent/test-bisect-dependent.t
1338 1335 +++ $TESTTMP/anothertests/bisect-dependent/test-bisect-dependent.t.err
1339 1336 @@ -1,2 +1,2 @@
1340 1337 $ tail -1 $TESTDIR/../bisect/test-bisect.t
1341 1338 - pass
1342 1339 + fail
1343 1340
1344 1341 ERROR: test-bisect-dependent.t output changed
1345 1342 !
1346 1343 Failed test-bisect-dependent.t: output changed
1347 1344 test-bisect-dependent.t broken by 72cbf122d116 (bad)
1348 1345 # Ran 1 tests, 0 skipped, 1 failed.
1349 1346 python hash seed: * (glob)
1350 1347 [1]
1351 1348
1352 1349 $ cd ..
1353 1350
1354 1351 Test a broken #if statement doesn't break run-tests threading.
1355 1352 ==============================================================
1356 1353 $ mkdir broken
1357 1354 $ cd broken
1358 1355 $ cat > test-broken.t <<EOF
1359 1356 > true
1360 1357 > #if notarealhghavefeature
1361 1358 > $ false
1362 1359 > #endif
1363 1360 > EOF
1364 1361 $ for f in 1 2 3 4 ; do
1365 1362 > cat > test-works-$f.t <<EOF
1366 1363 > This is test case $f
1367 1364 > $ sleep 1
1368 1365 > EOF
1369 1366 > done
1370 1367 $ rt -j 2
1371 1368 ....
1372 1369 # Ran 5 tests, 0 skipped, 0 failed.
1373 1370 skipped: unknown feature: notarealhghavefeature
1374 1371
1375 1372 $ cd ..
1376 1373 $ rm -rf broken
1377 1374
1378 1375 Test cases in .t files
1379 1376 ======================
1380 1377 $ mkdir cases
1381 1378 $ cd cases
1382 1379 $ cat > test-cases-abc.t <<'EOF'
1383 1380 > #testcases A B C
1384 1381 > $ V=B
1385 1382 > #if A
1386 1383 > $ V=A
1387 1384 > #endif
1388 1385 > #if C
1389 1386 > $ V=C
1390 1387 > #endif
1391 1388 > $ echo $V | sed 's/A/C/'
1392 1389 > C
1393 1390 > #if C
1394 1391 > $ [ $V = C ]
1395 1392 > #endif
1396 1393 > #if A
1397 1394 > $ [ $V = C ]
1398 1395 > [1]
1399 1396 > #endif
1400 1397 > #if no-C
1401 1398 > $ [ $V = C ]
1402 1399 > [1]
1403 1400 > #endif
1404 1401 > $ [ $V = D ]
1405 1402 > [1]
1406 1403 > EOF
1407 1404 $ rt
1408 1405 .
1409 1406 --- $TESTTMP/anothertests/cases/test-cases-abc.t
1410 1407 +++ $TESTTMP/anothertests/cases/test-cases-abc.t.B.err
1411 1408 @@ -7,7 +7,7 @@
1412 1409 $ V=C
1413 1410 #endif
1414 1411 $ echo $V | sed 's/A/C/'
1415 1412 - C
1416 1413 + B
1417 1414 #if C
1418 1415 $ [ $V = C ]
1419 1416 #endif
1420 1417
1421 1418 ERROR: test-cases-abc.t (case B) output changed
1422 1419 !.
1423 1420 Failed test-cases-abc.t (case B): output changed
1424 1421 # Ran 3 tests, 0 skipped, 1 failed.
1425 1422 python hash seed: * (glob)
1426 1423 [1]
1427 1424
1428 1425 --restart works
1429 1426
1430 1427 $ rt --restart
1431 1428
1432 1429 --- $TESTTMP/anothertests/cases/test-cases-abc.t
1433 1430 +++ $TESTTMP/anothertests/cases/test-cases-abc.t.B.err
1434 1431 @@ -7,7 +7,7 @@
1435 1432 $ V=C
1436 1433 #endif
1437 1434 $ echo $V | sed 's/A/C/'
1438 1435 - C
1439 1436 + B
1440 1437 #if C
1441 1438 $ [ $V = C ]
1442 1439 #endif
1443 1440
1444 1441 ERROR: test-cases-abc.t (case B) output changed
1445 1442 !.
1446 1443 Failed test-cases-abc.t (case B): output changed
1447 1444 # Ran 2 tests, 0 skipped, 1 failed.
1448 1445 python hash seed: * (glob)
1449 1446 [1]
1450 1447
1451 1448 --restart works with outputdir
1452 1449
1453 1450 $ mkdir output
1454 1451 $ mv test-cases-abc.t.B.err output
1455 1452 $ rt --restart --outputdir output
1456 1453
1457 1454 --- $TESTTMP/anothertests/cases/test-cases-abc.t
1458 1455 +++ $TESTTMP/anothertests/cases/output/test-cases-abc.t.B.err
1459 1456 @@ -7,7 +7,7 @@
1460 1457 $ V=C
1461 1458 #endif
1462 1459 $ echo $V | sed 's/A/C/'
1463 1460 - C
1464 1461 + B
1465 1462 #if C
1466 1463 $ [ $V = C ]
1467 1464 #endif
1468 1465
1469 1466 ERROR: test-cases-abc.t (case B) output changed
1470 1467 !.
1471 1468 Failed test-cases-abc.t (case B): output changed
1472 1469 # Ran 2 tests, 0 skipped, 1 failed.
1473 1470 python hash seed: * (glob)
1474 1471 [1]
General Comments 0
You need to be logged in to leave comments. Login now