6 print "1..0 # Skip until we figure out why it exists with no output just after the plan\n";
18 use Test::Harness qw(execute_tests);
20 # unset this global when self-testing ('testcover' and etc issue)
21 local $ENV{HARNESS_PERL_SWITCHES};
25 # if the harness wants to save the resulting TAP we shouldn't
26 # do it for our internal calls
27 local $ENV{PERL_TEST_HARNESS_DUMP_TAP} = 0;
29 my $TEST_DIR = 't/sample-tests';
51 descriptive die die_head_end die_last_minute duplicates
52 head_end head_fail inc_taint junk_before_plan lone_not_bug
53 no_nums no_output schwern sequence_misparse shbang_misparse
54 simple simple_fail skip skip_nomsg skipall skipall_nomsg
55 stdout_stderr switches taint todo_inline
56 todo_misparse too_many vms_nit
60 't/sample-tests/die' => {
65 'name' => 't/sample-tests/die',
68 't/sample-tests/die_head_end' => {
73 'name' => 't/sample-tests/die_head_end',
76 't/sample-tests/die_last_minute' => {
81 'name' => 't/sample-tests/die_last_minute',
84 't/sample-tests/duplicates' => {
89 'name' => 't/sample-tests/duplicates',
92 't/sample-tests/head_fail' => {
97 'name' => 't/sample-tests/head_fail',
100 't/sample-tests/inc_taint' => {
105 'name' => 't/sample-tests/inc_taint',
108 't/sample-tests/no_nums' => {
113 'name' => 't/sample-tests/no_nums',
116 't/sample-tests/no_output' => {
121 'name' => 't/sample-tests/no_output',
124 't/sample-tests/simple_fail' => {
129 'name' => 't/sample-tests/simple_fail',
132 't/sample-tests/switches' => {
137 'name' => 't/sample-tests/switches',
140 't/sample-tests/todo_misparse' => {
145 'name' => 't/sample-tests/todo_misparse',
148 't/sample-tests/too_many' => {
153 'name' => 't/sample-tests/too_many',
156 't/sample-tests/vms_nit' => {
161 'name' => 't/sample-tests/vms_nit',
166 't/sample-tests/todo_inline' => {
171 'name' => 't/sample-tests/todo_inline',
190 't/sample-tests/die' => {
195 'name' => 't/sample-tests/die',
215 't/sample-tests/die_head_end' => {
220 'name' => 't/sample-tests/die_head_end',
238 'die_last_minute' => {
240 't/sample-tests/die_last_minute' => {
245 'name' => 't/sample-tests/die_last_minute',
265 't/sample-tests/duplicates' => {
270 'name' => 't/sample-tests/duplicates',
306 't/sample-tests/head_fail' => {
311 'name' => 't/sample-tests/head_fail',
331 't/sample-tests/inc_taint' => {
336 'name' => 't/sample-tests/inc_taint',
354 'junk_before_plan' => {
388 't/sample-tests/no_nums' => {
393 'name' => 't/sample-tests/no_nums',
413 't/sample-tests/no_output' => {
418 'name' => 't/sample-tests/no_output',
452 'sequence_misparse' => {
468 'shbang_misparse' => {
502 't/sample-tests/simple_fail' => {
507 'name' => 't/sample-tests/simple_fail',
607 't/sample-tests/switches' => {
612 'name' => 't/sample-tests/switches',
661 'require' => 5.008001,
666 't/sample-tests/todo_inline' => {
671 'name' => 't/sample-tests/todo_inline',
690 't/sample-tests/todo_misparse' => {
695 'name' => 't/sample-tests/todo_misparse',
715 't/sample-tests/too_many' => {
720 'name' => 't/sample-tests/too_many',
740 't/sample-tests/vms_nit' => {
745 'name' => 't/sample-tests/vms_nit',
765 my $num_tests = ( keys %$results ) * $PER_LOOP;
767 plan tests => $num_tests;
771 return File::Spec->catfile( split /\//, $name );
778 while ( my ( $file, $want ) = each %$hash ) {
779 if ( exists $want->{name} ) {
780 $want->{name} = local_name( $want->{name} );
782 $new->{ local_name($file) } = $want;
789 return $hash unless $^O eq 'VMS';
791 while ( my ( $file, $want ) = each %$hash ) {
792 for ( qw( estat wstat ) ) {
793 if ( exists $want->{$_} ) {
794 $want->{$_} = $want->{$_} ? 1 : 0;
804 # Silence harness output
805 *TAP::Formatter::Console::_output = sub {
811 for my $test_key ( sort keys %$results ) {
812 my $result = $results->{$test_key};
814 if ( $result->{require} && $] < $result->{require} ) {
815 skip "Test requires Perl $result->{require}, we have $]", 4;
817 my @test_names = split( /,/, $test_key );
819 = map { File::Spec->catfile( $TEST_DIR, $_ ) } @test_names;
821 # For now we supress STDERR because it crufts up /our/ test
822 # results. Should probably capture and analyse it.
823 local ( *OLDERR, *OLDOUT );
824 open OLDERR, '>&STDERR' or die $!;
825 open OLDOUT, '>&STDOUT' or die $!;
826 my $devnull = File::Spec->devnull;
827 open STDERR, ">$devnull" or die $!;
828 open STDOUT, ">$devnull" or die $!;
830 my ( $tot, $fail, $todo, $harness, $aggregate )
831 = execute_tests( tests => \@test_files );
833 open STDERR, '>&OLDERR' or die $!;
834 open STDOUT, '>&OLDOUT' or die $!;
836 my $bench = delete $tot->{bench};
837 isa_ok $bench, 'Benchmark';
839 # Localise filenames in failed, todo
840 my $lfailed = vague_status( local_result( $result->{failed} ) );
841 my $ltodo = vague_status( local_result( $result->{todo} ) );
844 # diag Dumper( [ $lfailed, $ltodo ] );
846 is_deeply $tot, $result->{totals}, "totals match for $test_key";
847 is_deeply vague_status($fail), $lfailed,
848 "failure summary matches for $test_key";
849 is_deeply vague_status($todo), $ltodo,
850 "todo summary matches for $test_key";