X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Frun%2Fexit.t;h=5305bd2ae2c890720f9d1c00e5e6fcc9eda19845;hb=c64c7340e1f13afc97ec321c9d90ab6478848f76;hp=828b83228ac6e317d99ca3950f6f70db21e89716;hpb=14cf881c49354abdedb2f64b4fde446a92185e9f;p=p5sagit%2Fp5-mst-13.2.git diff --git a/t/run/exit.t b/t/run/exit.t index 828b832..5305bd2 100644 --- a/t/run/exit.t +++ b/t/run/exit.t @@ -5,11 +5,11 @@ BEGIN { chdir 't' if -d 't'; - @INC = '../lib'; + @INC = qw(. ../lib); } -# VMS needs -e "...", most everything else works better with ' -my $quote = $^O eq 'VMS' ? q{"} : q{'}; +# VMS and Windows need -e "...", most everything else works better with ' +my $quote = $^O =~ /^(VMS|MSWin\d+)$/ ? q{"} : q{'}; # Run some code, return its wait status. sub run { @@ -18,15 +18,51 @@ sub run { return system($cmd.$quote.$code.$quote); } -use Test::More tests => 3; +BEGIN { + $numtests = ($^O eq 'VMS') ? 7 : 3; +} -my $exit; +require "test.pl"; +plan(tests => $numtests); + +my $exit, $exit_arg; $exit = run('exit'); is( $exit >> 8, 0, 'Normal exit' ); -$exit = run('exit 42'); -is( $exit >> 8, 42, 'Non-zero exit' ); +if ($^O ne 'VMS') { + + $exit = run('exit 42'); + is( $exit >> 8, 42, 'Non-zero exit' ); + +} else { + +# On VMS, successful returns from system() are always 0, warnings are 1, +# errors are 2, and fatal errors are 4. + + $exit = run("exit 196609"); # %CLI-S-NORMAL + is( $exit >> 8, 0, 'success exit' ); + + $exit = run("exit 196611"); # %CLI-I-NORMAL + is( $exit >> 8, 0, 'informational exit' ); + + $exit = run("exit 196608"); # %CLI-W-NORMAL + is( $exit >> 8, 1, 'warning exit' ); + + $exit = run("exit 196610"); # %CLI-E-NORMAL + is( $exit >> 8, 2, 'error exit' ); + + $exit = run("exit 196612"); # %CLI-F-NORMAL + is( $exit >> 8, 4, 'fatal error exit' ); +} + +$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'; -$exit = run('END { $? = 42 }'); -is( $exit >> 8, 42, 'Changing $? in END block' ); +is( $exit >> 8, $exit_arg, 'Changing $? in END block' );