4 if ( $ENV{PERL_CORE} ) {
19 use Test::Harness qw(execute_tests);
21 # unset this global when self-testing ('testcover' and etc issue)
22 local $ENV{HARNESS_PERL_SWITCHES};
25 = $ENV{PERL_CORE} ? '../ext/Test/Harness/t/sample-tests' : 't/sample-tests';
29 # if the harness wants to save the resulting TAP we shouldn't
30 # do it for our internal calls
31 local $ENV{PERL_TEST_HARNESS_DUMP_TAP} = 0;
54 descriptive die die_head_end die_last_minute duplicates
55 head_end head_fail inc_taint junk_before_plan lone_not_bug
56 no_nums no_output schwern sequence_misparse shbang_misparse
57 simple simple_fail skip skip_nomsg skipall skipall_nomsg
58 stdout_stderr taint todo_inline
59 todo_misparse too_many vms_nit
68 'name' => "$TEST_DIR/die",
71 "$TEST_DIR/die_head_end" => {
76 'name' => "$TEST_DIR/die_head_end",
79 "$TEST_DIR/die_last_minute" => {
84 'name' => "$TEST_DIR/die_last_minute",
87 "$TEST_DIR/duplicates" => {
92 'name' => "$TEST_DIR/duplicates",
95 "$TEST_DIR/head_fail" => {
100 'name' => "$TEST_DIR/head_fail",
103 "$TEST_DIR/inc_taint" => {
108 'name' => "$TEST_DIR/inc_taint",
111 "$TEST_DIR/no_nums" => {
116 'name' => "$TEST_DIR/no_nums",
119 "$TEST_DIR/no_output" => {
124 'name' => "$TEST_DIR/no_output",
127 "$TEST_DIR/simple_fail" => {
132 'name' => "$TEST_DIR/simple_fail",
135 "$TEST_DIR/todo_misparse" => {
140 'name' => "$TEST_DIR/todo_misparse",
143 "$TEST_DIR/too_many" => {
148 'name' => "$TEST_DIR/too_many",
151 "$TEST_DIR/vms_nit" => {
156 'name' => "$TEST_DIR/vms_nit",
161 "$TEST_DIR/todo_inline" => {
166 'name' => "$TEST_DIR/todo_inline",
190 'name' => "$TEST_DIR/die",
210 "$TEST_DIR/die_head_end" => {
215 'name' => "$TEST_DIR/die_head_end",
233 'die_last_minute' => {
235 "$TEST_DIR/die_last_minute" => {
240 'name' => "$TEST_DIR/die_last_minute",
260 "$TEST_DIR/duplicates" => {
265 'name' => "$TEST_DIR/duplicates",
301 "$TEST_DIR/head_fail" => {
306 'name' => "$TEST_DIR/head_fail",
326 "$TEST_DIR/inc_taint" => {
331 'name' => "$TEST_DIR/inc_taint",
349 'junk_before_plan' => {
383 "$TEST_DIR/no_nums" => {
388 'name' => "$TEST_DIR/no_nums",
408 "$TEST_DIR/no_output" => {
413 'name' => "$TEST_DIR/no_output",
447 'sequence_misparse' => {
463 'shbang_misparse' => {
497 "$TEST_DIR/simple_fail" => {
502 'name' => "$TEST_DIR/simple_fail",
602 ( $ENV{PERL5OPT} || '' ) =~ m{(?:^|\s)-[dM]};
605 "$TEST_DIR/switches" => {
610 'name' => "$TEST_DIR/switches",
659 'require' => 5.008001,
664 "$TEST_DIR/todo_inline" => {
669 'name' => "$TEST_DIR/todo_inline",
688 "$TEST_DIR/todo_misparse" => {
693 'name' => "$TEST_DIR/todo_misparse",
713 "$TEST_DIR/too_many" => {
718 'name' => "$TEST_DIR/too_many",
738 "$TEST_DIR/vms_nit" => {
743 'name' => "$TEST_DIR/vms_nit",
763 my $num_tests = ( keys %$results ) * $PER_LOOP;
765 plan tests => $num_tests;
769 return File::Spec->catfile( split /\//, $name );
776 while ( my ( $file, $want ) = each %$hash ) {
777 if ( exists $want->{name} ) {
778 $want->{name} = local_name( $want->{name} );
780 $new->{ local_name($file) } = $want;
787 return $hash unless $^O eq 'VMS';
789 while ( my ( $file, $want ) = each %$hash ) {
790 for (qw( estat wstat )) {
791 if ( exists $want->{$_} ) {
792 $want->{$_} = $want->{$_} ? 1 : 0;
802 # Silence harness output
803 *TAP::Formatter::Console::_output = sub {
809 for my $test_key ( sort keys %$results ) {
810 my $result = $results->{$test_key};
812 if ( $result->{require} && $] < $result->{require} ) {
813 skip "Test requires Perl $result->{require}, we have $]", 4;
816 if ( my $skip_if = $result->{skip_if} ) {
818 "Test '$test_key' can't run properly in this environment", 4
822 my @test_names = split( /,/, $test_key );
824 = map { File::Spec->catfile( $TEST_DIR, $_ ) } @test_names;
826 # For now we supress STDERR because it crufts up /our/ test
827 # results. Should probably capture and analyse it.
828 local ( *OLDERR, *OLDOUT );
829 open OLDERR, '>&STDERR' or die $!;
830 open OLDOUT, '>&STDOUT' or die $!;
831 my $devnull = File::Spec->devnull;
832 open STDERR, ">$devnull" or die $!;
833 open STDOUT, ">$devnull" or die $!;
835 my ( $tot, $fail, $todo, $harness, $aggregate )
836 = execute_tests( tests => \@test_files );
838 open STDERR, '>&OLDERR' or die $!;
839 open STDOUT, '>&OLDOUT' or die $!;
841 my $bench = delete $tot->{bench};
842 isa_ok $bench, 'Benchmark';
844 # Localise filenames in failed, todo
845 my $lfailed = vague_status( local_result( $result->{failed} ) );
846 my $ltodo = vague_status( local_result( $result->{todo} ) );
849 # diag Dumper( [ $lfailed, $ltodo ] );
851 is_deeply $tot, $result->{totals}, "totals match for $test_key";
852 is_deeply vague_status($fail), $lfailed,
853 "failure summary matches for $test_key";
854 is_deeply vague_status($todo), $ltodo,
855 "todo summary matches for $test_key";