Avoid potentially empty struct.
[p5sagit/p5-mst-13.2.git] / t / run / exit.t
index 7b91cf3..53ba4ea 100644 (file)
@@ -5,7 +5,7 @@
 
 BEGIN {
     chdir 't' if -d 't';
-    @INC = '../lib';
+    @INC = qw(. ../lib);
 }
 
 # VMS and Windows need -e "...", most everything else works better with '
@@ -18,11 +18,15 @@ sub run {
     return system($cmd.$quote.$code.$quote);
 }
 
-## can't use this in 'use Test::More' yet
-##my $numtests = ($^O eq 'VMS') ? 7 : 3; 
+BEGIN {
+    # MacOS system() doesn't have good return value
+    $numtests = ($^O eq 'VMS') ? 7 : ($^O eq 'MacOS') ? 0 : 3; 
+}
 
-use Test::More tests => 'no_plan';
+require "test.pl";
+plan(tests => $numtests);
 
+if ($^O ne 'MacOS') {
 my $exit, $exit_arg;
 
 $exit = run('exit');
@@ -54,5 +58,14 @@ if ($^O ne 'VMS') {
   is( $exit >> 8, 4,             'fatal error exit' );
 }
 
-$exit = run('END { $? = 42 }');
-is( $exit >> 8, 42,             'Changing $? in END block' );
+$exit_arg = 42;
+$exit = run("END { \$? = $exit_arg }");
+
+# On VMS, in the child process the actual exit status will be SS$_ABORT, 
+# which is what you get from any non-zero value of $? that has been 
+# dePOSIXified by STATUS_POSIX_SET.  In the parent process, all we'll 
+# see are the severity bits (0-2) shifted left by 8.
+$exit_arg = (44 & 7) if $^O eq 'VMS';  
+
+is( $exit >> 8, $exit_arg,             'Changing $? in END block' );
+}