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