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