Move the modules, tests, prove and Changes file from lib/ to
[p5sagit/p5-mst-13.2.git] / ext / Test / Harness / t / compat / test-harness-compat.t
CommitLineData
b965d173 1#!/usr/bin/perl -w
2
3BEGIN {
4 if ($ENV{PERL_CORE}) {
5 # FIXME
6 print "1..0 # Skip until we figure out why it exists with no output just after the plan\n";
7 exit 0;
8 }
9}
10
11use strict;
f7c69158 12
b965d173 13use lib 't/lib';
14
15use Test::More;
16
17use File::Spec;
18
19use Test::Harness qw(execute_tests);
20
21# unset this global when self-testing ('testcover' and etc issue)
22local $ENV{HARNESS_PERL_SWITCHES};
23
24{
25
26 # if the harness wants to save the resulting TAP we shouldn't
27 # do it for our internal calls
28 local $ENV{PERL_TEST_HARNESS_DUMP_TAP} = 0;
29
30 my $TEST_DIR = 't/sample-tests';
31 my $PER_LOOP = 4;
32
33 my $results = {
34 'descriptive' => {
35 'failed' => {},
36 'todo' => {},
37 'totals' => {
38 'bad' => 0,
39 'bonus' => 0,
40 'files' => 1,
41 'good' => 1,
42 'max' => 5,
43 'ok' => 5,
44 'skipped' => 0,
45 'sub_skipped' => 0,
46 'tests' => 1,
47 'todo' => 0
48 }
49 },
50 join(
51 ',', qw(
52 descriptive die die_head_end die_last_minute duplicates
53 head_end head_fail inc_taint junk_before_plan lone_not_bug
54 no_nums no_output schwern sequence_misparse shbang_misparse
55 simple simple_fail skip skip_nomsg skipall skipall_nomsg
f7c69158 56 stdout_stderr taint todo_inline
b965d173 57 todo_misparse too_many vms_nit
58 )
59 ) => {
60 'failed' => {
61 't/sample-tests/die' => {
62 'canon' => '??',
63 'estat' => 1,
64 'failed' => '??',
65 'max' => '??',
66 'name' => 't/sample-tests/die',
67 'wstat' => '256'
68 },
69 't/sample-tests/die_head_end' => {
70 'canon' => '??',
71 'estat' => 1,
72 'failed' => '??',
73 'max' => '??',
74 'name' => 't/sample-tests/die_head_end',
75 'wstat' => '256'
76 },
77 't/sample-tests/die_last_minute' => {
78 'canon' => '??',
79 'estat' => 1,
80 'failed' => 0,
81 'max' => 4,
82 'name' => 't/sample-tests/die_last_minute',
83 'wstat' => '256'
84 },
85 't/sample-tests/duplicates' => {
86 'canon' => '??',
87 'estat' => '',
88 'failed' => '??',
89 'max' => 10,
90 'name' => 't/sample-tests/duplicates',
91 'wstat' => ''
92 },
93 't/sample-tests/head_fail' => {
94 'canon' => 2,
95 'estat' => '',
96 'failed' => 1,
97 'max' => 4,
98 'name' => 't/sample-tests/head_fail',
99 'wstat' => ''
100 },
101 't/sample-tests/inc_taint' => {
102 'canon' => 1,
103 'estat' => 1,
104 'failed' => 1,
105 'max' => 1,
106 'name' => 't/sample-tests/inc_taint',
107 'wstat' => '256'
108 },
109 't/sample-tests/no_nums' => {
110 'canon' => 3,
111 'estat' => '',
112 'failed' => 1,
113 'max' => 5,
114 'name' => 't/sample-tests/no_nums',
115 'wstat' => ''
116 },
117 't/sample-tests/no_output' => {
118 'canon' => '??',
119 'estat' => '',
120 'failed' => '??',
121 'max' => '??',
122 'name' => 't/sample-tests/no_output',
123 'wstat' => ''
124 },
125 't/sample-tests/simple_fail' => {
126 'canon' => '2 5',
127 'estat' => '',
128 'failed' => 2,
129 'max' => 5,
130 'name' => 't/sample-tests/simple_fail',
131 'wstat' => ''
132 },
b965d173 133 't/sample-tests/todo_misparse' => {
134 'canon' => 1,
135 'estat' => '',
136 'failed' => 1,
137 'max' => 1,
138 'name' => 't/sample-tests/todo_misparse',
139 'wstat' => ''
140 },
141 't/sample-tests/too_many' => {
142 'canon' => '4-7',
143 'estat' => 4,
144 'failed' => 4,
145 'max' => 3,
146 'name' => 't/sample-tests/too_many',
147 'wstat' => '1024'
148 },
149 't/sample-tests/vms_nit' => {
150 'canon' => 1,
151 'estat' => '',
152 'failed' => 1,
153 'max' => 2,
154 'name' => 't/sample-tests/vms_nit',
155 'wstat' => ''
156 }
157 },
158 'todo' => {
159 't/sample-tests/todo_inline' => {
160 'canon' => 2,
161 'estat' => '',
162 'failed' => 1,
163 'max' => 2,
164 'name' => 't/sample-tests/todo_inline',
165 'wstat' => ''
166 }
167 },
168 'totals' => {
f7c69158 169 'bad' => 12,
b965d173 170 'bonus' => 1,
f7c69158 171 'files' => 27,
b965d173 172 'good' => 15,
f7c69158 173 'max' => 76,
b965d173 174 'ok' => 78,
175 'skipped' => 2,
176 'sub_skipped' => 2,
f7c69158 177 'tests' => 27,
b965d173 178 'todo' => 2
179 }
180 },
181 'die' => {
182 'failed' => {
183 't/sample-tests/die' => {
184 'canon' => '??',
185 'estat' => 1,
186 'failed' => '??',
187 'max' => '??',
188 'name' => 't/sample-tests/die',
189 'wstat' => '256'
190 }
191 },
192 'todo' => {},
193 'totals' => {
194 'bad' => 1,
195 'bonus' => 0,
196 'files' => 1,
197 'good' => 0,
198 'max' => 0,
199 'ok' => 0,
200 'skipped' => 0,
201 'sub_skipped' => 0,
202 'tests' => 1,
203 'todo' => 0
204 }
205 },
206 'die_head_end' => {
207 'failed' => {
208 't/sample-tests/die_head_end' => {
209 'canon' => '??',
210 'estat' => 1,
211 'failed' => '??',
212 'max' => '??',
213 'name' => 't/sample-tests/die_head_end',
214 'wstat' => '256'
215 }
216 },
217 'todo' => {},
218 'totals' => {
219 'bad' => 1,
220 'bonus' => 0,
221 'files' => 1,
222 'good' => 0,
223 'max' => 0,
224 'ok' => 4,
225 'skipped' => 0,
226 'sub_skipped' => 0,
227 'tests' => 1,
228 'todo' => 0
229 }
230 },
231 'die_last_minute' => {
232 'failed' => {
233 't/sample-tests/die_last_minute' => {
234 'canon' => '??',
235 'estat' => 1,
236 'failed' => 0,
237 'max' => 4,
238 'name' => 't/sample-tests/die_last_minute',
239 'wstat' => '256'
240 }
241 },
242 'todo' => {},
243 'totals' => {
244 'bad' => 1,
245 'bonus' => 0,
246 'files' => 1,
247 'good' => 0,
248 'max' => 4,
249 'ok' => 4,
250 'skipped' => 0,
251 'sub_skipped' => 0,
252 'tests' => 1,
253 'todo' => 0
254 }
255 },
256 'duplicates' => {
257 'failed' => {
258 't/sample-tests/duplicates' => {
259 'canon' => '??',
260 'estat' => '',
261 'failed' => '??',
262 'max' => 10,
263 'name' => 't/sample-tests/duplicates',
264 'wstat' => ''
265 }
266 },
267 'todo' => {},
268 'totals' => {
269 'bad' => 1,
270 'bonus' => 0,
271 'files' => 1,
272 'good' => 0,
273 'max' => 10,
274 'ok' => 11,
275 'skipped' => 0,
276 'sub_skipped' => 0,
277 'tests' => 1,
278 'todo' => 0
279 }
280 },
281 'head_end' => {
282 'failed' => {},
283 'todo' => {},
284 'totals' => {
285 'bad' => 0,
286 'bonus' => 0,
287 'files' => 1,
288 'good' => 1,
289 'max' => 4,
290 'ok' => 4,
291 'skipped' => 0,
292 'sub_skipped' => 0,
293 'tests' => 1,
294 'todo' => 0
295 }
296 },
297 'head_fail' => {
298 'failed' => {
299 't/sample-tests/head_fail' => {
300 'canon' => 2,
301 'estat' => '',
302 'failed' => 1,
303 'max' => 4,
304 'name' => 't/sample-tests/head_fail',
305 'wstat' => ''
306 }
307 },
308 'todo' => {},
309 'totals' => {
310 'bad' => 1,
311 'bonus' => 0,
312 'files' => 1,
313 'good' => 0,
314 'max' => 4,
315 'ok' => 3,
316 'skipped' => 0,
317 'sub_skipped' => 0,
318 'tests' => 1,
319 'todo' => 0
320 }
321 },
322 'inc_taint' => {
323 'failed' => {
324 't/sample-tests/inc_taint' => {
325 'canon' => 1,
326 'estat' => 1,
327 'failed' => 1,
328 'max' => 1,
329 'name' => 't/sample-tests/inc_taint',
330 'wstat' => '256'
331 }
332 },
333 'todo' => {},
334 'totals' => {
335 'bad' => 1,
336 'bonus' => 0,
337 'files' => 1,
338 'good' => 0,
339 'max' => 1,
340 'ok' => 0,
341 'skipped' => 0,
342 'sub_skipped' => 0,
343 'tests' => 1,
344 'todo' => 0
345 }
346 },
347 'junk_before_plan' => {
348 'failed' => {},
349 'todo' => {},
350 'totals' => {
351 'bad' => 0,
352 'bonus' => 0,
353 'files' => 1,
354 'good' => 1,
355 'max' => 1,
356 'ok' => 1,
357 'skipped' => 0,
358 'sub_skipped' => 0,
359 'tests' => 1,
360 'todo' => 0
361 }
362 },
363 'lone_not_bug' => {
364 'failed' => {},
365 'todo' => {},
366 'totals' => {
367 'bad' => 0,
368 'bonus' => 0,
369 'files' => 1,
370 'good' => 1,
371 'max' => 4,
372 'ok' => 4,
373 'skipped' => 0,
374 'sub_skipped' => 0,
375 'tests' => 1,
376 'todo' => 0
377 }
378 },
379 'no_nums' => {
380 'failed' => {
381 't/sample-tests/no_nums' => {
382 'canon' => 3,
383 'estat' => '',
384 'failed' => 1,
385 'max' => 5,
386 'name' => 't/sample-tests/no_nums',
387 'wstat' => ''
388 }
389 },
390 'todo' => {},
391 'totals' => {
392 'bad' => 1,
393 'bonus' => 0,
394 'files' => 1,
395 'good' => 0,
396 'max' => 5,
397 'ok' => 4,
398 'skipped' => 0,
399 'sub_skipped' => 0,
400 'tests' => 1,
401 'todo' => 0
402 }
403 },
404 'no_output' => {
405 'failed' => {
406 't/sample-tests/no_output' => {
407 'canon' => '??',
408 'estat' => '',
409 'failed' => '??',
410 'max' => '??',
411 'name' => 't/sample-tests/no_output',
412 'wstat' => ''
413 }
414 },
415 'todo' => {},
416 'totals' => {
417 'bad' => 1,
418 'bonus' => 0,
419 'files' => 1,
420 'good' => 0,
421 'max' => 0,
422 'ok' => 0,
423 'skipped' => 0,
424 'sub_skipped' => 0,
425 'tests' => 1,
426 'todo' => 0
427 }
428 },
429 'schwern' => {
430 'failed' => {},
431 'todo' => {},
432 'totals' => {
433 'bad' => 0,
434 'bonus' => 0,
435 'files' => 1,
436 'good' => 1,
437 'max' => 1,
438 'ok' => 1,
439 'skipped' => 0,
440 'sub_skipped' => 0,
441 'tests' => 1,
442 'todo' => 0
443 }
444 },
445 'sequence_misparse' => {
446 'failed' => {},
447 'todo' => {},
448 'totals' => {
449 'bad' => 0,
450 'bonus' => 0,
451 'files' => 1,
452 'good' => 1,
453 'max' => 5,
454 'ok' => 5,
455 'skipped' => 0,
456 'sub_skipped' => 0,
457 'tests' => 1,
458 'todo' => 0
459 }
460 },
461 'shbang_misparse' => {
462 'failed' => {},
463 'todo' => {},
464 'totals' => {
465 'bad' => 0,
466 'bonus' => 0,
467 'files' => 1,
468 'good' => 1,
469 'max' => 2,
470 'ok' => 2,
471 'skipped' => 0,
472 'sub_skipped' => 0,
473 'tests' => 1,
474 'todo' => 0
475 }
476 },
477 'simple' => {
478 'failed' => {},
479 'todo' => {},
480 'totals' => {
481 'bad' => 0,
482 'bonus' => 0,
483 'files' => 1,
484 'good' => 1,
485 'max' => 5,
486 'ok' => 5,
487 'skipped' => 0,
488 'sub_skipped' => 0,
489 'tests' => 1,
490 'todo' => 0
491 }
492 },
493 'simple_fail' => {
494 'failed' => {
495 't/sample-tests/simple_fail' => {
496 'canon' => '2 5',
497 'estat' => '',
498 'failed' => 2,
499 'max' => 5,
500 'name' => 't/sample-tests/simple_fail',
501 'wstat' => ''
502 }
503 },
504 'todo' => {},
505 'totals' => {
506 'bad' => 1,
507 'bonus' => 0,
508 'files' => 1,
509 'good' => 0,
510 'max' => 5,
511 'ok' => 3,
512 'skipped' => 0,
513 'sub_skipped' => 0,
514 'tests' => 1,
515 'todo' => 0
516 }
517 },
518 'skip' => {
519 'failed' => {},
520 'todo' => {},
521 'totals' => {
522 'bad' => 0,
523 'bonus' => 0,
524 'files' => 1,
525 'good' => 1,
526 'max' => 5,
527 'ok' => 5,
528 'skipped' => 0,
529 'sub_skipped' => 1,
530 'tests' => 1,
531 'todo' => 0
532 }
533 },
534 'skip_nomsg' => {
535 'failed' => {},
536 'todo' => {},
537 'totals' => {
538 'bad' => 0,
539 'bonus' => 0,
540 'files' => 1,
541 'good' => 1,
542 'max' => 1,
543 'ok' => 1,
544 'skipped' => 0,
545 'sub_skipped' => 1,
546 'tests' => 1,
547 'todo' => 0
548 }
549 },
550 'skipall' => {
551 'failed' => {},
552 'todo' => {},
553 'totals' => {
554 'bad' => 0,
555 'bonus' => 0,
556 'files' => 1,
557 'good' => 1,
558 'max' => 0,
559 'ok' => 0,
560 'skipped' => 1,
561 'sub_skipped' => 0,
562 'tests' => 1,
563 'todo' => 0
564 }
565 },
566 'skipall_nomsg' => {
567 'failed' => {},
568 'todo' => {},
569 'totals' => {
570 'bad' => 0,
571 'bonus' => 0,
572 'files' => 1,
573 'good' => 1,
574 'max' => 0,
575 'ok' => 0,
576 'skipped' => 1,
577 'sub_skipped' => 0,
578 'tests' => 1,
579 'todo' => 0
580 }
581 },
582 'stdout_stderr' => {
583 'failed' => {},
584 'todo' => {},
585 'totals' => {
586 'bad' => 0,
587 'bonus' => 0,
588 'files' => 1,
589 'good' => 1,
590 'max' => 4,
591 'ok' => 4,
592 'skipped' => 0,
593 'sub_skipped' => 0,
594 'tests' => 1,
595 'todo' => 0
596 }
597 },
598 'switches' => {
f7c69158 599 'skip_if' => sub {
600 ( $ENV{PERL5OPT} || '' ) =~ m{(?:^|\s)-[dM]};
601 },
b965d173 602 'failed' => {
603 't/sample-tests/switches' => {
604 'canon' => 1,
605 'estat' => '',
606 'failed' => 1,
607 'max' => 1,
608 'name' => 't/sample-tests/switches',
609 'wstat' => ''
610 }
611 },
612 'todo' => {},
613 'totals' => {
614 'bad' => 1,
615 'bonus' => 0,
616 'files' => 1,
617 'good' => 0,
618 'max' => 1,
619 'ok' => 0,
620 'skipped' => 0,
621 'sub_skipped' => 0,
622 'tests' => 1,
623 'todo' => 0
624 }
625 },
626 'taint' => {
627 'failed' => {},
628 'todo' => {},
629 'totals' => {
630 'bad' => 0,
631 'bonus' => 0,
632 'files' => 1,
633 'good' => 1,
634 'max' => 1,
635 'ok' => 1,
636 'skipped' => 0,
637 'sub_skipped' => 0,
638 'tests' => 1,
639 'todo' => 0
640 }
641 },
642 'taint_warn' => {
643 'failed' => {},
644 'todo' => {},
645 'totals' => {
646 'bad' => 0,
647 'bonus' => 0,
648 'files' => 1,
649 'good' => 1,
650 'max' => 1,
651 'ok' => 1,
652 'skipped' => 0,
653 'sub_skipped' => 0,
654 'tests' => 1,
655 'todo' => 0
656 },
657 'require' => 5.008001,
658 },
659 'todo_inline' => {
660 'failed' => {},
661 'todo' => {
662 't/sample-tests/todo_inline' => {
663 'canon' => 2,
664 'estat' => '',
665 'failed' => 1,
666 'max' => 2,
667 'name' => 't/sample-tests/todo_inline',
668 'wstat' => ''
669 }
670 },
671 'totals' => {
672 'bad' => 0,
673 'bonus' => 1,
674 'files' => 1,
675 'good' => 1,
676 'max' => 3,
677 'ok' => 3,
678 'skipped' => 0,
679 'sub_skipped' => 0,
680 'tests' => 1,
681 'todo' => 2
682 }
683 },
684 'todo_misparse' => {
685 'failed' => {
686 't/sample-tests/todo_misparse' => {
687 'canon' => 1,
688 'estat' => '',
689 'failed' => 1,
690 'max' => 1,
691 'name' => 't/sample-tests/todo_misparse',
692 'wstat' => ''
693 }
694 },
695 'todo' => {},
696 'totals' => {
697 'bad' => 1,
698 'bonus' => 0,
699 'files' => 1,
700 'good' => 0,
701 'max' => 1,
702 'ok' => 0,
703 'skipped' => 0,
704 'sub_skipped' => 0,
705 'tests' => 1,
706 'todo' => 0
707 }
708 },
709 'too_many' => {
710 'failed' => {
711 't/sample-tests/too_many' => {
712 'canon' => '4-7',
713 'estat' => 4,
714 'failed' => 4,
715 'max' => 3,
716 'name' => 't/sample-tests/too_many',
717 'wstat' => '1024'
718 }
719 },
720 'todo' => {},
721 'totals' => {
722 'bad' => 1,
723 'bonus' => 0,
724 'files' => 1,
725 'good' => 0,
726 'max' => 3,
727 'ok' => 7,
728 'skipped' => 0,
729 'sub_skipped' => 0,
730 'tests' => 1,
731 'todo' => 0
732 }
733 },
734 'vms_nit' => {
735 'failed' => {
736 't/sample-tests/vms_nit' => {
737 'canon' => 1,
738 'estat' => '',
739 'failed' => 1,
740 'max' => 2,
741 'name' => 't/sample-tests/vms_nit',
742 'wstat' => ''
743 }
744 },
745 'todo' => {},
746 'totals' => {
747 'bad' => 1,
748 'bonus' => 0,
749 'files' => 1,
750 'good' => 0,
751 'max' => 2,
752 'ok' => 1,
753 'skipped' => 0,
754 'sub_skipped' => 0,
755 'tests' => 1,
756 'todo' => 0
757 }
758 }
759 };
760
761 my $num_tests = ( keys %$results ) * $PER_LOOP;
762
763 plan tests => $num_tests;
764
765 sub local_name {
766 my $name = shift;
767 return File::Spec->catfile( split /\//, $name );
768 }
769
770 sub local_result {
771 my $hash = shift;
772 my $new = {};
773
774 while ( my ( $file, $want ) = each %$hash ) {
775 if ( exists $want->{name} ) {
776 $want->{name} = local_name( $want->{name} );
777 }
778 $new->{ local_name($file) } = $want;
779 }
780 return $new;
781 }
782
783 sub vague_status {
784 my $hash = shift;
785 return $hash unless $^O eq 'VMS';
786
787 while ( my ( $file, $want ) = each %$hash ) {
788 for ( qw( estat wstat ) ) {
789 if ( exists $want->{$_} ) {
790 $want->{$_} = $want->{$_} ? 1 : 0;
791 }
792 }
793 }
794 return $hash
795 }
796
797 {
798 local $^W = 0;
799
800 # Silence harness output
801 *TAP::Formatter::Console::_output = sub {
802
803 # do nothing
804 };
805 }
806
807 for my $test_key ( sort keys %$results ) {
808 my $result = $results->{$test_key};
809 SKIP: {
810 if ( $result->{require} && $] < $result->{require} ) {
811 skip "Test requires Perl $result->{require}, we have $]", 4;
812 }
f7c69158 813
814 if ( my $skip_if = $result->{skip_if} ) {
815 skip
816 "Test '$test_key' can't run properly in this environment", 4
817 if $skip_if->();
818 }
819
b965d173 820 my @test_names = split( /,/, $test_key );
821 my @test_files
822 = map { File::Spec->catfile( $TEST_DIR, $_ ) } @test_names;
823
824 # For now we supress STDERR because it crufts up /our/ test
825 # results. Should probably capture and analyse it.
826 local ( *OLDERR, *OLDOUT );
827 open OLDERR, '>&STDERR' or die $!;
828 open OLDOUT, '>&STDOUT' or die $!;
829 my $devnull = File::Spec->devnull;
830 open STDERR, ">$devnull" or die $!;
831 open STDOUT, ">$devnull" or die $!;
832
833 my ( $tot, $fail, $todo, $harness, $aggregate )
834 = execute_tests( tests => \@test_files );
835
836 open STDERR, '>&OLDERR' or die $!;
837 open STDOUT, '>&OLDOUT' or die $!;
838
839 my $bench = delete $tot->{bench};
840 isa_ok $bench, 'Benchmark';
841
842 # Localise filenames in failed, todo
843 my $lfailed = vague_status( local_result( $result->{failed} ) );
844 my $ltodo = vague_status( local_result( $result->{todo} ) );
845
846 # use Data::Dumper;
847 # diag Dumper( [ $lfailed, $ltodo ] );
848
849 is_deeply $tot, $result->{totals}, "totals match for $test_key";
850 is_deeply vague_status($fail), $lfailed,
851 "failure summary matches for $test_key";
852 is_deeply vague_status($todo), $ltodo,
853 "todo summary matches for $test_key";
854 }
855 }
856}