Okay, here' another shot at a test for perl's exit codes. This one should work fine on VMS and everything else. Of course, its going to fail on VMS, but that's because non-zero exit codes appear to be broken. --- /dev/null Sat Apr 14 22:09:58 2001 +++ t/run/exit.t Fri Jun 29 19:31:36 2001 @@ -0,0 +1,32 @@ +#!./perl +# +# Tests for perl exit codes, playing with $?, etc... + + +BEGIN { + chdir 't' if -d 't'; + @INC = '../lib'; +} + +# VMS needs -e "...", most everything else works better with ' +my $quote = $^O eq 'VMS' ? q{"} : q{'}; + +# Run some code, return its wait status. +sub run { + my($code) = shift; + my $cmd = "$^X -e "; + return system($cmd.$quote.$code.$quote); +} + +use Test::More tests => 3; + +my $exit; + +$exit = run('exit'); +is( $exit >> 8, 0, 'Normal exit' ); + +$exit = run('exit 42'); +is( $exit >> 8, 42, 'Non-zero exit' ); + +$exit = run('END { $? = 42 }'); +is( $exit >> 8, 42, 'Changing $? in END block' ); --- MANIFEST 2001/06/29 23:32:06 1.1 +++ MANIFEST 2001/06/29 23:32:40 @@ -2055,6 +2055,7 @@ t/pod/testpchk.pl Module to test Pod::Checker for a given file t/pod/testpods/lib/Pod/Stuff.pm Sample data for find.t t/README Instructions for regression tests +t/run/exit.t Test perl's exit status. t/run/runenv.t Test if perl honors its environment variables. t/TEST The regression tester t/TestInit.pm Preamble library for core tests -- Michael G. Schwern <schwern@pobox.com> http://www.pobox.com/~schwern/ Perl6 Quality Assurance <perl-qa@perl.org> Kwalitee Is Job One BOFH excuse #18: excess surge protectionThread Next