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