##// END OF EJS Templates
tests: avoid echo with backslash escapes...
Martin von Zweigbergk -
r35417:417fa230 default
parent child Browse files
Show More
@@ -1,1583 +1,1585
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
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
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 $ echo " $ echo 'saved backup bundle to \$TESTTMP/foo.hg'" >> test-failure.t
707 $ echo " saved backup bundle to \$TESTTMP/foo.hg" >> test-failure.t
708 $ echo " $ echo 'saved backup bundle to \$TESTTMP/foo.hg'" >> test-failure.t
709 $ echo " saved backup bundle to \$TESTTMP\\foo.hg" >> test-failure.t
710 $ echo " $ echo 'saved backup bundle to \$TESTTMP/foo.hg'" >> test-failure.t
711 $ echo " saved backup bundle to \$TESTTMP/*.hg (glob)" >> test-failure.t
706 $ cat >> test-failure.t <<EOF
707 > $ echo 'saved backup bundle to \$TESTTMP/foo.hg'
708 > saved backup bundle to \$TESTTMP/foo.hg
709 > $ echo 'saved backup bundle to \$TESTTMP/foo.hg'
710 > saved backup bundle to $TESTTMP\\foo.hg
711 > $ echo 'saved backup bundle to \$TESTTMP/foo.hg'
712 > saved backup bundle to \$TESTTMP/*.hg (glob)
713 > EOF
712 714 $ echo 'y' | rt -i 2>&1
713 715
714 716 --- $TESTTMP/test-failure.t
715 717 +++ $TESTTMP/test-failure.t.err
716 718 @@ -1,5 +1,5 @@
717 719 $ echo babar
718 720 - rataxes
719 721 + babar
720 722 This is a noop statement so that
721 723 this test is still more bytes than success.
722 724 pad pad pad pad............................................................
723 725 @@ -11,6 +11,6 @@
724 726 $ echo 'saved backup bundle to $TESTTMP/foo.hg'
725 727 saved backup bundle to $TESTTMP/foo.hg
726 728 $ echo 'saved backup bundle to $TESTTMP/foo.hg'
727 729 - saved backup bundle to $TESTTMP\foo.hg
728 730 + saved backup bundle to $TESTTMP/foo.hg
729 731 $ echo 'saved backup bundle to $TESTTMP/foo.hg'
730 732 saved backup bundle to $TESTTMP/*.hg (glob)
731 733 Accept this change? [n] ..
732 734 # Ran 2 tests, 0 skipped, 0 failed.
733 735
734 736 $ sed -e 's,(glob)$,&<,g' test-failure.t
735 737 $ echo babar
736 738 babar
737 739 This is a noop statement so that
738 740 this test is still more bytes than success.
739 741 pad pad pad pad............................................................
740 742 pad pad pad pad............................................................
741 743 pad pad pad pad............................................................
742 744 pad pad pad pad............................................................
743 745 pad pad pad pad............................................................
744 746 pad pad pad pad............................................................
745 747 $ echo 'saved backup bundle to $TESTTMP/foo.hg'
746 748 saved backup bundle to $TESTTMP/foo.hg
747 749 $ echo 'saved backup bundle to $TESTTMP/foo.hg'
748 750 saved backup bundle to $TESTTMP/foo.hg
749 751 $ echo 'saved backup bundle to $TESTTMP/foo.hg'
750 752 saved backup bundle to $TESTTMP/*.hg (glob)<
751 753
752 754 Race condition - test file was modified when test is running
753 755
754 756 $ TESTRACEDIR=`pwd`
755 757 $ export TESTRACEDIR
756 758 $ cat > test-race.t <<EOF
757 759 > $ echo 1
758 760 > $ echo "# a new line" >> $TESTRACEDIR/test-race.t
759 761 > EOF
760 762
761 763 $ rt -i test-race.t
762 764
763 765 --- $TESTTMP/test-race.t
764 766 +++ $TESTTMP/test-race.t.err
765 767 @@ -1,2 +1,3 @@
766 768 $ echo 1
767 769 + 1
768 770 $ echo "# a new line" >> $TESTTMP/test-race.t
769 771 Reference output has changed (run again to prompt changes)
770 772 ERROR: test-race.t output changed
771 773 !
772 774 Failed test-race.t: output changed
773 775 # Ran 1 tests, 0 skipped, 1 failed.
774 776 python hash seed: * (glob)
775 777 [1]
776 778
777 779 $ rm test-race.t
778 780
779 781 When "#testcases" is used in .t files
780 782
781 783 $ cat >> test-cases.t <<EOF
782 784 > #testcases a b
783 785 > #if a
784 786 > $ echo 1
785 787 > #endif
786 788 > #if b
787 789 > $ echo 2
788 790 > #endif
789 791 > EOF
790 792
791 793 $ cat <<EOF | rt -i test-cases.t 2>&1
792 794 > y
793 795 > y
794 796 > EOF
795 797
796 798 --- $TESTTMP/test-cases.t
797 799 +++ $TESTTMP/test-cases.t.a.err
798 800 @@ -1,6 +1,7 @@
799 801 #testcases a b
800 802 #if a
801 803 $ echo 1
802 804 + 1
803 805 #endif
804 806 #if b
805 807 $ echo 2
806 808 Accept this change? [n] .
807 809 --- $TESTTMP/test-cases.t
808 810 +++ $TESTTMP/test-cases.t.b.err
809 811 @@ -5,4 +5,5 @@
810 812 #endif
811 813 #if b
812 814 $ echo 2
813 815 + 2
814 816 #endif
815 817 Accept this change? [n] .
816 818 # Ran 2 tests, 0 skipped, 0 failed.
817 819
818 820 $ cat test-cases.t
819 821 #testcases a b
820 822 #if a
821 823 $ echo 1
822 824 1
823 825 #endif
824 826 #if b
825 827 $ echo 2
826 828 2
827 829 #endif
828 830
829 831 $ cat >> test-cases.t <<'EOF'
830 832 > #if a
831 833 > $ NAME=A
832 834 > #else
833 835 > $ NAME=B
834 836 > #endif
835 837 > $ echo $NAME
836 838 > A (a !)
837 839 > B (b !)
838 840 > EOF
839 841 $ rt test-cases.t
840 842 ..
841 843 # Ran 2 tests, 0 skipped, 0 failed.
842 844
843 845 $ rm test-cases.t
844 846
845 847 (reinstall)
846 848 $ mv backup test-failure.t
847 849
848 850 No Diff
849 851 ===============
850 852
851 853 $ rt --nodiff
852 854 !.
853 855 Failed test-failure.t: output changed
854 856 # Ran 2 tests, 0 skipped, 1 failed.
855 857 python hash seed: * (glob)
856 858 [1]
857 859
858 860 test --tmpdir support
859 861 $ rt --tmpdir=$TESTTMP/keep test-success.t
860 862
861 863 Keeping testtmp dir: $TESTTMP/keep/child1/test-success.t
862 864 Keeping threadtmp dir: $TESTTMP/keep/child1
863 865 .
864 866 # Ran 1 tests, 0 skipped, 0 failed.
865 867
866 868 timeouts
867 869 ========
868 870 $ cat > test-timeout.t <<EOF
869 871 > $ sleep 2
870 872 > $ echo pass
871 873 > pass
872 874 > EOF
873 875 > echo '#require slow' > test-slow-timeout.t
874 876 > cat test-timeout.t >> test-slow-timeout.t
875 877 $ rt --timeout=1 --slowtimeout=3 test-timeout.t test-slow-timeout.t
876 878 st
877 879 Skipped test-slow-timeout.t: missing feature: allow slow tests (use --allow-slow-tests)
878 880 Failed test-timeout.t: timed out
879 881 # Ran 1 tests, 1 skipped, 1 failed.
880 882 python hash seed: * (glob)
881 883 [1]
882 884 $ rt --timeout=1 --slowtimeout=3 \
883 885 > test-timeout.t test-slow-timeout.t --allow-slow-tests
884 886 .t
885 887 Failed test-timeout.t: timed out
886 888 # Ran 2 tests, 0 skipped, 1 failed.
887 889 python hash seed: * (glob)
888 890 [1]
889 891 $ rm test-timeout.t test-slow-timeout.t
890 892
891 893 test for --time
892 894 ==================
893 895
894 896 $ rt test-success.t --time
895 897 .
896 898 # Ran 1 tests, 0 skipped, 0 failed.
897 899 # Producing time report
898 900 start end cuser csys real Test
899 901 \s*[\d\.]{5} \s*[\d\.]{5} \s*[\d\.]{5} \s*[\d\.]{5} \s*[\d\.]{5} test-success.t (re)
900 902
901 903 test for --time with --job enabled
902 904 ====================================
903 905
904 906 $ rt test-success.t --time --jobs 2
905 907 .
906 908 # Ran 1 tests, 0 skipped, 0 failed.
907 909 # Producing time report
908 910 start end cuser csys real Test
909 911 \s*[\d\.]{5} \s*[\d\.]{5} \s*[\d\.]{5} \s*[\d\.]{5} \s*[\d\.]{5} test-success.t (re)
910 912
911 913 Skips
912 914 ================
913 915 $ cat > test-skip.t <<EOF
914 916 > $ echo xyzzy
915 917 > #require false
916 918 > EOF
917 919 $ rt --nodiff
918 920 !.s
919 921 Skipped test-skip.t: missing feature: nail clipper
920 922 Failed test-failure.t: output changed
921 923 # Ran 2 tests, 1 skipped, 1 failed.
922 924 python hash seed: * (glob)
923 925 [1]
924 926
925 927 $ rt --keyword xyzzy
926 928 .s
927 929 Skipped test-skip.t: missing feature: nail clipper
928 930 # Ran 2 tests, 2 skipped, 0 failed.
929 931
930 932 Skips with xml
931 933 $ rt --keyword xyzzy \
932 934 > --xunit=xunit.xml
933 935 .s
934 936 Skipped test-skip.t: missing feature: nail clipper
935 937 # Ran 2 tests, 2 skipped, 0 failed.
936 938 $ cat xunit.xml
937 939 <?xml version="1.0" encoding="utf-8"?>
938 940 <testsuite errors="0" failures="0" name="run-tests" skipped="2" tests="2">
939 941 <testcase name="test-success.t" time="*"/> (glob)
940 942 <testcase name="test-skip.t">
941 943 <skipped>
942 944 <![CDATA[missing feature: nail clipper]]> </skipped>
943 945 </testcase>
944 946 </testsuite>
945 947
946 948 Missing skips or blacklisted skips don't count as executed:
947 949 $ echo test-failure.t > blacklist
948 950 $ rt --blacklist=blacklist --json\
949 951 > test-failure.t test-bogus.t
950 952 ss
951 953 Skipped test-bogus.t: Doesn't exist
952 954 Skipped test-failure.t: blacklisted
953 955 # Ran 0 tests, 2 skipped, 0 failed.
954 956 $ cat report.json
955 957 testreport ={
956 958 "test-bogus.t": {
957 959 "result": "skip"
958 960 },
959 961 "test-failure.t": {
960 962 "result": "skip"
961 963 }
962 964 } (no-eol)
963 965
964 966 Whitelist trumps blacklist
965 967 $ echo test-failure.t > whitelist
966 968 $ rt --blacklist=blacklist --whitelist=whitelist --json\
967 969 > test-failure.t test-bogus.t
968 970 s
969 971 --- $TESTTMP/test-failure.t
970 972 +++ $TESTTMP/test-failure.t.err
971 973 @@ -1,5 +1,5 @@
972 974 $ echo babar
973 975 - rataxes
974 976 + babar
975 977 This is a noop statement so that
976 978 this test is still more bytes than success.
977 979 pad pad pad pad............................................................
978 980
979 981 ERROR: test-failure.t output changed
980 982 !
981 983 Skipped test-bogus.t: Doesn't exist
982 984 Failed test-failure.t: output changed
983 985 # Ran 1 tests, 1 skipped, 1 failed.
984 986 python hash seed: * (glob)
985 987 [1]
986 988
987 989 Ensure that --test-list causes only the tests listed in that file to
988 990 be executed.
989 991 $ echo test-success.t >> onlytest
990 992 $ rt --test-list=onlytest
991 993 .
992 994 # Ran 1 tests, 0 skipped, 0 failed.
993 995 $ echo test-bogus.t >> anothertest
994 996 $ rt --test-list=onlytest --test-list=anothertest
995 997 s.
996 998 Skipped test-bogus.t: Doesn't exist
997 999 # Ran 1 tests, 1 skipped, 0 failed.
998 1000 $ rm onlytest anothertest
999 1001
1000 1002 test for --json
1001 1003 ==================
1002 1004
1003 1005 $ rt --json
1004 1006
1005 1007 --- $TESTTMP/test-failure.t
1006 1008 +++ $TESTTMP/test-failure.t.err
1007 1009 @@ -1,5 +1,5 @@
1008 1010 $ echo babar
1009 1011 - rataxes
1010 1012 + babar
1011 1013 This is a noop statement so that
1012 1014 this test is still more bytes than success.
1013 1015 pad pad pad pad............................................................
1014 1016
1015 1017 ERROR: test-failure.t output changed
1016 1018 !.s
1017 1019 Skipped test-skip.t: missing feature: nail clipper
1018 1020 Failed test-failure.t: output changed
1019 1021 # Ran 2 tests, 1 skipped, 1 failed.
1020 1022 python hash seed: * (glob)
1021 1023 [1]
1022 1024
1023 1025 $ cat report.json
1024 1026 testreport ={
1025 1027 "test-failure.t": [\{] (re)
1026 1028 "csys": "\s*[\d\.]{4,5}", ? (re)
1027 1029 "cuser": "\s*[\d\.]{4,5}", ? (re)
1028 1030 "diff": "---.+\+\+\+.+", ? (re)
1029 1031 "end": "\s*[\d\.]{4,5}", ? (re)
1030 1032 "result": "failure", ? (re)
1031 1033 "start": "\s*[\d\.]{4,5}", ? (re)
1032 1034 "time": "\s*[\d\.]{4,5}" (re)
1033 1035 }, ? (re)
1034 1036 "test-skip.t": {
1035 1037 "csys": "\s*[\d\.]{4,5}", ? (re)
1036 1038 "cuser": "\s*[\d\.]{4,5}", ? (re)
1037 1039 "diff": "", ? (re)
1038 1040 "end": "\s*[\d\.]{4,5}", ? (re)
1039 1041 "result": "skip", ? (re)
1040 1042 "start": "\s*[\d\.]{4,5}", ? (re)
1041 1043 "time": "\s*[\d\.]{4,5}" (re)
1042 1044 }, ? (re)
1043 1045 "test-success.t": [\{] (re)
1044 1046 "csys": "\s*[\d\.]{4,5}", ? (re)
1045 1047 "cuser": "\s*[\d\.]{4,5}", ? (re)
1046 1048 "diff": "", ? (re)
1047 1049 "end": "\s*[\d\.]{4,5}", ? (re)
1048 1050 "result": "success", ? (re)
1049 1051 "start": "\s*[\d\.]{4,5}", ? (re)
1050 1052 "time": "\s*[\d\.]{4,5}" (re)
1051 1053 }
1052 1054 } (no-eol)
1053 1055 --json with --outputdir
1054 1056
1055 1057 $ rm report.json
1056 1058 $ rm -r output
1057 1059 $ mkdir output
1058 1060 $ rt --json --outputdir output
1059 1061
1060 1062 --- $TESTTMP/test-failure.t
1061 1063 +++ $TESTTMP/output/test-failure.t.err
1062 1064 @@ -1,5 +1,5 @@
1063 1065 $ echo babar
1064 1066 - rataxes
1065 1067 + babar
1066 1068 This is a noop statement so that
1067 1069 this test is still more bytes than success.
1068 1070 pad pad pad pad............................................................
1069 1071
1070 1072 ERROR: test-failure.t output changed
1071 1073 !.s
1072 1074 Skipped test-skip.t: missing feature: nail clipper
1073 1075 Failed test-failure.t: output changed
1074 1076 # Ran 2 tests, 1 skipped, 1 failed.
1075 1077 python hash seed: * (glob)
1076 1078 [1]
1077 1079 $ f report.json
1078 1080 report.json: file not found
1079 1081 $ cat output/report.json
1080 1082 testreport ={
1081 1083 "test-failure.t": [\{] (re)
1082 1084 "csys": "\s*[\d\.]{4,5}", ? (re)
1083 1085 "cuser": "\s*[\d\.]{4,5}", ? (re)
1084 1086 "diff": "---.+\+\+\+.+", ? (re)
1085 1087 "end": "\s*[\d\.]{4,5}", ? (re)
1086 1088 "result": "failure", ? (re)
1087 1089 "start": "\s*[\d\.]{4,5}", ? (re)
1088 1090 "time": "\s*[\d\.]{4,5}" (re)
1089 1091 }, ? (re)
1090 1092 "test-skip.t": {
1091 1093 "csys": "\s*[\d\.]{4,5}", ? (re)
1092 1094 "cuser": "\s*[\d\.]{4,5}", ? (re)
1093 1095 "diff": "", ? (re)
1094 1096 "end": "\s*[\d\.]{4,5}", ? (re)
1095 1097 "result": "skip", ? (re)
1096 1098 "start": "\s*[\d\.]{4,5}", ? (re)
1097 1099 "time": "\s*[\d\.]{4,5}" (re)
1098 1100 }, ? (re)
1099 1101 "test-success.t": [\{] (re)
1100 1102 "csys": "\s*[\d\.]{4,5}", ? (re)
1101 1103 "cuser": "\s*[\d\.]{4,5}", ? (re)
1102 1104 "diff": "", ? (re)
1103 1105 "end": "\s*[\d\.]{4,5}", ? (re)
1104 1106 "result": "success", ? (re)
1105 1107 "start": "\s*[\d\.]{4,5}", ? (re)
1106 1108 "time": "\s*[\d\.]{4,5}" (re)
1107 1109 }
1108 1110 } (no-eol)
1109 1111 $ ls -a output
1110 1112 .
1111 1113 ..
1112 1114 .testtimes
1113 1115 report.json
1114 1116 test-failure.t.err
1115 1117
1116 1118 Test that failed test accepted through interactive are properly reported:
1117 1119
1118 1120 $ cp test-failure.t backup
1119 1121 $ echo y | rt --json -i
1120 1122
1121 1123 --- $TESTTMP/test-failure.t
1122 1124 +++ $TESTTMP/test-failure.t.err
1123 1125 @@ -1,5 +1,5 @@
1124 1126 $ echo babar
1125 1127 - rataxes
1126 1128 + babar
1127 1129 This is a noop statement so that
1128 1130 this test is still more bytes than success.
1129 1131 pad pad pad pad............................................................
1130 1132 Accept this change? [n] ..s
1131 1133 Skipped test-skip.t: missing feature: nail clipper
1132 1134 # Ran 2 tests, 1 skipped, 0 failed.
1133 1135
1134 1136 $ cat report.json
1135 1137 testreport ={
1136 1138 "test-failure.t": [\{] (re)
1137 1139 "csys": "\s*[\d\.]{4,5}", ? (re)
1138 1140 "cuser": "\s*[\d\.]{4,5}", ? (re)
1139 1141 "diff": "", ? (re)
1140 1142 "end": "\s*[\d\.]{4,5}", ? (re)
1141 1143 "result": "success", ? (re)
1142 1144 "start": "\s*[\d\.]{4,5}", ? (re)
1143 1145 "time": "\s*[\d\.]{4,5}" (re)
1144 1146 }, ? (re)
1145 1147 "test-skip.t": {
1146 1148 "csys": "\s*[\d\.]{4,5}", ? (re)
1147 1149 "cuser": "\s*[\d\.]{4,5}", ? (re)
1148 1150 "diff": "", ? (re)
1149 1151 "end": "\s*[\d\.]{4,5}", ? (re)
1150 1152 "result": "skip", ? (re)
1151 1153 "start": "\s*[\d\.]{4,5}", ? (re)
1152 1154 "time": "\s*[\d\.]{4,5}" (re)
1153 1155 }, ? (re)
1154 1156 "test-success.t": [\{] (re)
1155 1157 "csys": "\s*[\d\.]{4,5}", ? (re)
1156 1158 "cuser": "\s*[\d\.]{4,5}", ? (re)
1157 1159 "diff": "", ? (re)
1158 1160 "end": "\s*[\d\.]{4,5}", ? (re)
1159 1161 "result": "success", ? (re)
1160 1162 "start": "\s*[\d\.]{4,5}", ? (re)
1161 1163 "time": "\s*[\d\.]{4,5}" (re)
1162 1164 }
1163 1165 } (no-eol)
1164 1166 $ mv backup test-failure.t
1165 1167
1166 1168 backslash on end of line with glob matching is handled properly
1167 1169
1168 1170 $ cat > test-glob-backslash.t << EOF
1169 1171 > $ echo 'foo bar \\'
1170 1172 > foo * \ (glob)
1171 1173 > EOF
1172 1174
1173 1175 $ rt test-glob-backslash.t
1174 1176 .
1175 1177 # Ran 1 tests, 0 skipped, 0 failed.
1176 1178
1177 1179 $ rm -f test-glob-backslash.t
1178 1180
1179 1181 Test globbing of local IP addresses
1180 1182 $ echo 172.16.18.1
1181 1183 $LOCALIP (glob)
1182 1184 $ echo dead:beef::1
1183 1185 $LOCALIP (glob)
1184 1186
1185 1187 Test reusability for third party tools
1186 1188 ======================================
1187 1189
1188 1190 $ mkdir "$TESTTMP"/anothertests
1189 1191 $ cd "$TESTTMP"/anothertests
1190 1192
1191 1193 test that `run-tests.py` can execute hghave, even if it runs not in
1192 1194 Mercurial source tree.
1193 1195
1194 1196 $ cat > test-hghave.t <<EOF
1195 1197 > #require true
1196 1198 > $ echo foo
1197 1199 > foo
1198 1200 > EOF
1199 1201 $ rt test-hghave.t
1200 1202 .
1201 1203 # Ran 1 tests, 0 skipped, 0 failed.
1202 1204
1203 1205 test that RUNTESTDIR refers the directory, in which `run-tests.py` now
1204 1206 running is placed.
1205 1207
1206 1208 $ cat > test-runtestdir.t <<EOF
1207 1209 > - $TESTDIR, in which test-run-tests.t is placed
1208 1210 > - \$TESTDIR, in which test-runtestdir.t is placed (expanded at runtime)
1209 1211 > - \$RUNTESTDIR, in which run-tests.py is placed (expanded at runtime)
1210 1212 >
1211 1213 > #if windows
1212 1214 > $ test "\$TESTDIR" = "$TESTTMP\anothertests"
1213 1215 > #else
1214 1216 > $ test "\$TESTDIR" = "$TESTTMP"/anothertests
1215 1217 > #endif
1216 1218 > If this prints a path, that means RUNTESTDIR didn't equal
1217 1219 > TESTDIR as it should have.
1218 1220 > $ test "\$RUNTESTDIR" = "$TESTDIR" || echo "\$RUNTESTDIR"
1219 1221 > This should print the start of check-code. If this passes but the
1220 1222 > previous check failed, that means we found a copy of check-code at whatever
1221 1223 > RUNTESTSDIR ended up containing, even though it doesn't match TESTDIR.
1222 1224 > $ head -n 3 "\$RUNTESTDIR"/../contrib/check-code.py | sed 's@.!.*python@#!USRBINENVPY@'
1223 1225 > #!USRBINENVPY
1224 1226 > #
1225 1227 > # check-code - a style and portability checker for Mercurial
1226 1228 > EOF
1227 1229 $ rt test-runtestdir.t
1228 1230 .
1229 1231 # Ran 1 tests, 0 skipped, 0 failed.
1230 1232
1231 1233 #if execbit
1232 1234
1233 1235 test that TESTDIR is referred in PATH
1234 1236
1235 1237 $ cat > custom-command.sh <<EOF
1236 1238 > #!/bin/sh
1237 1239 > echo "hello world"
1238 1240 > EOF
1239 1241 $ chmod +x custom-command.sh
1240 1242 $ cat > test-testdir-path.t <<EOF
1241 1243 > $ custom-command.sh
1242 1244 > hello world
1243 1245 > EOF
1244 1246 $ rt test-testdir-path.t
1245 1247 .
1246 1248 # Ran 1 tests, 0 skipped, 0 failed.
1247 1249
1248 1250 #endif
1249 1251
1250 1252 test support for --allow-slow-tests
1251 1253 $ cat > test-very-slow-test.t <<EOF
1252 1254 > #require slow
1253 1255 > $ echo pass
1254 1256 > pass
1255 1257 > EOF
1256 1258 $ rt test-very-slow-test.t
1257 1259 s
1258 1260 Skipped test-very-slow-test.t: missing feature: allow slow tests (use --allow-slow-tests)
1259 1261 # Ran 0 tests, 1 skipped, 0 failed.
1260 1262 $ rt $HGTEST_RUN_TESTS_PURE --allow-slow-tests test-very-slow-test.t
1261 1263 .
1262 1264 # Ran 1 tests, 0 skipped, 0 failed.
1263 1265
1264 1266 support for running a test outside the current directory
1265 1267 $ mkdir nonlocal
1266 1268 $ cat > nonlocal/test-is-not-here.t << EOF
1267 1269 > $ echo pass
1268 1270 > pass
1269 1271 > EOF
1270 1272 $ rt nonlocal/test-is-not-here.t
1271 1273 .
1272 1274 # Ran 1 tests, 0 skipped, 0 failed.
1273 1275
1274 1276 support for automatically discovering test if arg is a folder
1275 1277 $ mkdir tmp && cd tmp
1276 1278
1277 1279 $ cat > test-uno.t << EOF
1278 1280 > $ echo line
1279 1281 > line
1280 1282 > EOF
1281 1283
1282 1284 $ cp test-uno.t test-dos.t
1283 1285 $ cd ..
1284 1286 $ cp -R tmp tmpp
1285 1287 $ cp tmp/test-uno.t test-solo.t
1286 1288
1287 1289 $ rt tmp/ test-solo.t tmpp
1288 1290 .....
1289 1291 # Ran 5 tests, 0 skipped, 0 failed.
1290 1292 $ rm -rf tmp tmpp
1291 1293
1292 1294 support for running run-tests.py from another directory
1293 1295 $ mkdir tmp && cd tmp
1294 1296
1295 1297 $ cat > useful-file.sh << EOF
1296 1298 > important command
1297 1299 > EOF
1298 1300
1299 1301 $ cat > test-folder.t << EOF
1300 1302 > $ cat \$TESTDIR/useful-file.sh
1301 1303 > important command
1302 1304 > EOF
1303 1305
1304 1306 $ cat > test-folder-fail.t << EOF
1305 1307 > $ cat \$TESTDIR/useful-file.sh
1306 1308 > important commando
1307 1309 > EOF
1308 1310
1309 1311 $ cd ..
1310 1312 $ rt tmp/test-*.t
1311 1313
1312 1314 --- $TESTTMP/anothertests/tmp/test-folder-fail.t
1313 1315 +++ $TESTTMP/anothertests/tmp/test-folder-fail.t.err
1314 1316 @@ -1,2 +1,2 @@
1315 1317 $ cat $TESTDIR/useful-file.sh
1316 1318 - important commando
1317 1319 + important command
1318 1320
1319 1321 ERROR: test-folder-fail.t output changed
1320 1322 !.
1321 1323 Failed test-folder-fail.t: output changed
1322 1324 # Ran 2 tests, 0 skipped, 1 failed.
1323 1325 python hash seed: * (glob)
1324 1326 [1]
1325 1327
1326 1328 support for bisecting failed tests automatically
1327 1329 $ hg init bisect
1328 1330 $ cd bisect
1329 1331 $ cat >> test-bisect.t <<EOF
1330 1332 > $ echo pass
1331 1333 > pass
1332 1334 > EOF
1333 1335 $ hg add test-bisect.t
1334 1336 $ hg ci -m 'good'
1335 1337 $ cat >> test-bisect.t <<EOF
1336 1338 > $ echo pass
1337 1339 > fail
1338 1340 > EOF
1339 1341 $ hg ci -m 'bad'
1340 1342 $ rt --known-good-rev=0 test-bisect.t
1341 1343
1342 1344 --- $TESTTMP/anothertests/bisect/test-bisect.t
1343 1345 +++ $TESTTMP/anothertests/bisect/test-bisect.t.err
1344 1346 @@ -1,4 +1,4 @@
1345 1347 $ echo pass
1346 1348 pass
1347 1349 $ echo pass
1348 1350 - fail
1349 1351 + pass
1350 1352
1351 1353 ERROR: test-bisect.t output changed
1352 1354 !
1353 1355 Failed test-bisect.t: output changed
1354 1356 test-bisect.t broken by 72cbf122d116 (bad)
1355 1357 # Ran 1 tests, 0 skipped, 1 failed.
1356 1358 python hash seed: * (glob)
1357 1359 [1]
1358 1360
1359 1361 $ cd ..
1360 1362
1361 1363 support bisecting a separate repo
1362 1364
1363 1365 $ hg init bisect-dependent
1364 1366 $ cd bisect-dependent
1365 1367 $ cat > test-bisect-dependent.t <<EOF
1366 1368 > $ tail -1 \$TESTDIR/../bisect/test-bisect.t
1367 1369 > pass
1368 1370 > EOF
1369 1371 $ hg commit -Am dependent test-bisect-dependent.t
1370 1372
1371 1373 $ rt --known-good-rev=0 test-bisect-dependent.t
1372 1374
1373 1375 --- $TESTTMP/anothertests/bisect-dependent/test-bisect-dependent.t
1374 1376 +++ $TESTTMP/anothertests/bisect-dependent/test-bisect-dependent.t.err
1375 1377 @@ -1,2 +1,2 @@
1376 1378 $ tail -1 $TESTDIR/../bisect/test-bisect.t
1377 1379 - pass
1378 1380 + fail
1379 1381
1380 1382 ERROR: test-bisect-dependent.t output changed
1381 1383 !
1382 1384 Failed test-bisect-dependent.t: output changed
1383 1385 Failed to identify failure point for test-bisect-dependent.t
1384 1386 # Ran 1 tests, 0 skipped, 1 failed.
1385 1387 python hash seed: * (glob)
1386 1388 [1]
1387 1389
1388 1390 $ rt --bisect-repo=../test-bisect test-bisect-dependent.t
1389 1391 usage: run-tests.py [options] [tests]
1390 1392 run-tests.py: error: --bisect-repo cannot be used without --known-good-rev
1391 1393 [2]
1392 1394
1393 1395 $ rt --known-good-rev=0 --bisect-repo=../bisect test-bisect-dependent.t
1394 1396
1395 1397 --- $TESTTMP/anothertests/bisect-dependent/test-bisect-dependent.t
1396 1398 +++ $TESTTMP/anothertests/bisect-dependent/test-bisect-dependent.t.err
1397 1399 @@ -1,2 +1,2 @@
1398 1400 $ tail -1 $TESTDIR/../bisect/test-bisect.t
1399 1401 - pass
1400 1402 + fail
1401 1403
1402 1404 ERROR: test-bisect-dependent.t output changed
1403 1405 !
1404 1406 Failed test-bisect-dependent.t: output changed
1405 1407 test-bisect-dependent.t broken by 72cbf122d116 (bad)
1406 1408 # Ran 1 tests, 0 skipped, 1 failed.
1407 1409 python hash seed: * (glob)
1408 1410 [1]
1409 1411
1410 1412 $ cd ..
1411 1413
1412 1414 Test a broken #if statement doesn't break run-tests threading.
1413 1415 ==============================================================
1414 1416 $ mkdir broken
1415 1417 $ cd broken
1416 1418 $ cat > test-broken.t <<EOF
1417 1419 > true
1418 1420 > #if notarealhghavefeature
1419 1421 > $ false
1420 1422 > #endif
1421 1423 > EOF
1422 1424 $ for f in 1 2 3 4 ; do
1423 1425 > cat > test-works-$f.t <<EOF
1424 1426 > This is test case $f
1425 1427 > $ sleep 1
1426 1428 > EOF
1427 1429 > done
1428 1430 $ rt -j 2
1429 1431 ....
1430 1432 # Ran 5 tests, 0 skipped, 0 failed.
1431 1433 skipped: unknown feature: notarealhghavefeature
1432 1434
1433 1435 $ cd ..
1434 1436 $ rm -rf broken
1435 1437
1436 1438 Test cases in .t files
1437 1439 ======================
1438 1440 $ mkdir cases
1439 1441 $ cd cases
1440 1442 $ cat > test-cases-abc.t <<'EOF'
1441 1443 > #testcases A B C
1442 1444 > $ V=B
1443 1445 > #if A
1444 1446 > $ V=A
1445 1447 > #endif
1446 1448 > #if C
1447 1449 > $ V=C
1448 1450 > #endif
1449 1451 > $ echo $V | sed 's/A/C/'
1450 1452 > C
1451 1453 > #if C
1452 1454 > $ [ $V = C ]
1453 1455 > #endif
1454 1456 > #if A
1455 1457 > $ [ $V = C ]
1456 1458 > [1]
1457 1459 > #endif
1458 1460 > #if no-C
1459 1461 > $ [ $V = C ]
1460 1462 > [1]
1461 1463 > #endif
1462 1464 > $ [ $V = D ]
1463 1465 > [1]
1464 1466 > EOF
1465 1467 $ rt
1466 1468 .
1467 1469 --- $TESTTMP/anothertests/cases/test-cases-abc.t
1468 1470 +++ $TESTTMP/anothertests/cases/test-cases-abc.t.B.err
1469 1471 @@ -7,7 +7,7 @@
1470 1472 $ V=C
1471 1473 #endif
1472 1474 $ echo $V | sed 's/A/C/'
1473 1475 - C
1474 1476 + B
1475 1477 #if C
1476 1478 $ [ $V = C ]
1477 1479 #endif
1478 1480
1479 1481 ERROR: test-cases-abc.t (case B) output changed
1480 1482 !.
1481 1483 Failed test-cases-abc.t (case B): output changed
1482 1484 # Ran 3 tests, 0 skipped, 1 failed.
1483 1485 python hash seed: * (glob)
1484 1486 [1]
1485 1487
1486 1488 --restart works
1487 1489
1488 1490 $ rt --restart
1489 1491
1490 1492 --- $TESTTMP/anothertests/cases/test-cases-abc.t
1491 1493 +++ $TESTTMP/anothertests/cases/test-cases-abc.t.B.err
1492 1494 @@ -7,7 +7,7 @@
1493 1495 $ V=C
1494 1496 #endif
1495 1497 $ echo $V | sed 's/A/C/'
1496 1498 - C
1497 1499 + B
1498 1500 #if C
1499 1501 $ [ $V = C ]
1500 1502 #endif
1501 1503
1502 1504 ERROR: test-cases-abc.t (case B) output changed
1503 1505 !.
1504 1506 Failed test-cases-abc.t (case B): output changed
1505 1507 # Ran 2 tests, 0 skipped, 1 failed.
1506 1508 python hash seed: * (glob)
1507 1509 [1]
1508 1510
1509 1511 --restart works with outputdir
1510 1512
1511 1513 $ mkdir output
1512 1514 $ mv test-cases-abc.t.B.err output
1513 1515 $ rt --restart --outputdir output
1514 1516
1515 1517 --- $TESTTMP/anothertests/cases/test-cases-abc.t
1516 1518 +++ $TESTTMP/anothertests/cases/output/test-cases-abc.t.B.err
1517 1519 @@ -7,7 +7,7 @@
1518 1520 $ V=C
1519 1521 #endif
1520 1522 $ echo $V | sed 's/A/C/'
1521 1523 - C
1522 1524 + B
1523 1525 #if C
1524 1526 $ [ $V = C ]
1525 1527 #endif
1526 1528
1527 1529 ERROR: test-cases-abc.t (case B) output changed
1528 1530 !.
1529 1531 Failed test-cases-abc.t (case B): output changed
1530 1532 # Ran 2 tests, 0 skipped, 1 failed.
1531 1533 python hash seed: * (glob)
1532 1534 [1]
1533 1535
1534 1536 Test automatic pattern replacement
1535 1537
1536 1538 $ cat << EOF >> common-pattern.py
1537 1539 > substitutions = [
1538 1540 > (br'foo-(.*)\\b',
1539 1541 > br'\$XXX=\\1\$'),
1540 1542 > (br'bar\\n',
1541 1543 > br'\$YYY$\\n'),
1542 1544 > ]
1543 1545 > EOF
1544 1546
1545 1547 $ cat << EOF >> test-substitution.t
1546 1548 > $ echo foo-12
1547 1549 > \$XXX=12$
1548 1550 > $ echo foo-42
1549 1551 > \$XXX=42$
1550 1552 > $ echo bar prior
1551 1553 > bar prior
1552 1554 > $ echo lastbar
1553 1555 > last\$YYY$
1554 1556 > $ echo foo-bar foo-baz
1555 1557 > EOF
1556 1558
1557 1559 $ rt test-substitution.t
1558 1560
1559 1561 --- $TESTTMP/anothertests/cases/test-substitution.t
1560 1562 +++ $TESTTMP/anothertests/cases/test-substitution.t.err
1561 1563 @@ -7,3 +7,4 @@
1562 1564 $ echo lastbar
1563 1565 last$YYY$
1564 1566 $ echo foo-bar foo-baz
1565 1567 + $XXX=bar foo-baz$
1566 1568
1567 1569 ERROR: test-substitution.t output changed
1568 1570 !
1569 1571 Failed test-substitution.t: output changed
1570 1572 # Ran 1 tests, 0 skipped, 1 failed.
1571 1573 python hash seed: * (glob)
1572 1574 [1]
1573 1575
1574 1576 --extra-config-opt works
1575 1577
1576 1578 $ cat << EOF >> test-config-opt.t
1577 1579 > $ hg init test-config-opt
1578 1580 > $ hg -R test-config-opt purge
1579 1581 > EOF
1580 1582
1581 1583 $ rt --extra-config-opt extensions.purge= test-config-opt.t
1582 1584 .
1583 1585 # Ran 1 tests, 0 skipped, 0 failed.
General Comments 0
You need to be logged in to leave comments. Login now