Integrate macperl patches #16926 and #16938;
[p5sagit/p5-mst-13.2.git] / lib / Test / Harness / t / test-harness.t
index ad948ac..f75f379 100644 (file)
@@ -10,7 +10,11 @@ BEGIN {
     }
 }
 
-my $SAMPLE_TESTS = $ENV{PERL_CORE} ? "lib/sample-tests" : "t/sample-tests";
+use File::Spec::Functions;
+
+my $SAMPLE_TESTS = $ENV{PERL_CORE}
+    ? catdir(curdir(), 'lib', 'sample-tests')
+    : catdir(curdir(), 't', 'sample-tests');
 
 use strict;
 
@@ -36,10 +40,10 @@ package main;
 use Test::More;
 
 my $IsVMS = $^O eq 'VMS';
+my $IsMacOS = $^O eq 'MacOS';
 
 # VMS uses native, not POSIX, exit codes.
-my $die_estat = $IsVMS ? 44 : 1;
-my $die_wstat = $IsVMS ? 1024 : 256;
+my $die_estat = $IsVMS ? 44 : $IsMacOS ? 0 : 1;
 
 my %samples = (
             simple            => {
@@ -158,6 +162,22 @@ my %samples = (
                                   failed => { },
                                   all_ok => 1,
                                  },
+            'skip_nomsg'      => {
+                                  total => {
+                                            bonus      => 0,
+                                            max        => 1,
+                                            'ok'       => 1,
+                                            files      => 1,
+                                            bad        => 0,
+                                            good       => 1,
+                                            tests      => 1,
+                                            sub_skipped=> 1,
+                                            'todo'     => 0,
+                                            skipped    => 0,
+                                           },
+                                  failed => { },
+                                  all_ok => 1,
+                                 },
             bailout           => 0,
             combined          => {
                                   total => {
@@ -229,7 +249,23 @@ my %samples = (
                                             },
                                   all_ok => 0,
                                  },
-            skip_all          => {
+            skipall          => {
+                                  total => {
+                                            bonus      => 0,
+                                            max        => 0,
+                                            'ok'       => 0,
+                                            files      => 1,
+                                            bad        => 0,
+                                            good       => 1,
+                                            tests      => 1,
+                                            sub_skipped=> 0,
+                                            'todo'     => 0,
+                                            skipped    => 1,
+                                           },
+                                  failed => { },
+                                  all_ok => 1,
+                                 },
+            skipall_nomsg   => {
                                   total => {
                                             bonus      => 0,
                                             max        => 0,
@@ -293,7 +329,6 @@ my %samples = (
                                            },
                                   failed => {
                                              estat      => $die_estat,
-                                             wstat      => $die_wstat,
                                              max        => '??',
                                              failed     => '??',
                                              canon      => '??',
@@ -316,7 +351,6 @@ my %samples = (
                                            },
                                   failed => {
                                              estat      => $die_estat,
-                                             wstat      => $die_wstat,
                                              max        => '??',
                                              failed     => '??',
                                              canon      => '??',
@@ -339,7 +373,6 @@ my %samples = (
                                            },
                                   failed => {
                                              estat      => $die_estat,
-                                             wstat      => $die_wstat,
                                              max        => 4,
                                              failed     => 0,
                                              canon      => '??',
@@ -364,9 +397,25 @@ my %samples = (
                                             },
                                   all_ok => 0,
                                  },
+            'shbang_misparse' => {
+                                  total => {
+                                            bonus      => 0,
+                                            max        => 2,
+                                            'ok'       => 2,
+                                            files      => 1,
+                                            bad        => 0,
+                                            good       => 1,
+                                            tests      => 1,
+                                            sub_skipped=> 0,
+                                            'todo'     => 0,
+                                            skipped    => 0,
+                                           },
+                                  failed => { },
+                                  all_ok => 1,
+                                 },
            );
 
-plan tests => (keys(%samples) * 4) + 1;
+plan tests => (keys(%samples) * 7) + 1;
 
 use Test::Harness;
 use_ok('Test::Harness');
@@ -377,29 +426,44 @@ tie *NULL, 'My::Dev::Null' or die $!;
 while (my($test, $expect) = each %samples) {
     # _run_all_tests() runs the tests but skips the formatting.
     my($totals, $failed);
+    my $warning;
     eval {
         select NULL;    # _run_all_tests() isn't as quiet as it should be.
+        local $SIG{__WARN__} = sub { $warning .= join '', @_; };
         ($totals, $failed) = 
-          Test::Harness::_run_all_tests("$SAMPLE_TESTS/$test");
+          Test::Harness::_run_all_tests(catfile($SAMPLE_TESTS, $test));
     };
     select STDOUT;
 
-    unless( $@ ) {
-        is( Test::Harness::_all_ok($totals), $expect->{all_ok},    
-                                                      "$test - all ok" );
-        ok( defined $expect->{total},                 "$test - has total" );
+    SKIP: {
+        skip "special tests for bailout", 1 unless $test eq 'bailout';
+        like( $@, '/Further testing stopped: GERONI/i' );
+    }
+
+    SKIP: {
+        skip "don't apply to a bailout", 5 if $test eq 'bailout';
+        is( $@, '' );
+        is( Test::Harness::_all_ok($totals), $expect->{all_ok},
+                                                  "$test - all ok" );
+        ok( defined $expect->{total},             "$test - has total" );
         is_deeply( {map { $_=>$totals->{$_} } keys %{$expect->{total}}},
                    $expect->{total},
-                                                         "$test - totals" );
-        is_deeply( {map { $_=>$failed->{"$SAMPLE_TESTS/$test"}{$_} }
-                        keys %{$expect->{failed}}},
+                                                  "$test - totals" );
+        is_deeply( {map { $_=>$failed->{catfile($SAMPLE_TESTS, $test)}{$_} }
+                    keys %{$expect->{failed}}},
                    $expect->{failed},
-                                                         "$test - failed" );
+                                                  "$test - failed" );
     }
-    else {      # special case for bailout
-        is( $test, 'bailout' );
-        like( $@, '/Further testing stopped: GERONI/i', $test );
-        pass( 'skipping for bailout' );
-        pass( 'skipping for bailout' );
+
+    SKIP: {
+        skip "special tests for bignum", 1 unless $test eq 'bignum';
+        is( $warning, <<WARN );
+Enourmous test number seen [test 100001]
+Can't detailize, too big.
+Enourmous test number seen [test 136211425]
+Can't detailize, too big.
+WARN
+
     }
+
 }