3 # Can't use Test.pm, that's a 5.005 thing.
7 if( $ENV{PERL_CORE} ) {
13 unless( eval { require File::Spec } ) {
14 print "1..0 # Skip Need File::Spec to run this test\n";
18 if( $^O eq 'VMS' && $] <= 5.00503 ) {
19 print "1..0 # Skip test will hang on older VMS perls\n";
23 if( $^O eq 'MacOS' ) {
24 print "1..0 # Skip exit status broken on Mac OS\n";
29 # Utility testing functions.
31 my($test, $name) = @_;
33 $ok .= "not " unless $test;
34 $ok .= "ok $test_num";
35 $ok .= " - $name" if defined $name;
44 my $IsVMS = $^O eq 'VMS';
46 print "# Ahh! I see you're running VMS.\n" if $IsVMS;
50 'success.plx' => [0, 0],
51 'one_fail.plx' => [1, 4],
52 'two_fail.plx' => [2, 4],
53 'five_fail.plx' => [5, 4],
54 'extras.plx' => [3, 4],
55 'too_few.plx' => [4, 4],
56 'death.plx' => [255, 4],
57 'last_minute_death.plx' => [255, 4],
58 'pre_plan_death.plx' => ['not zero', 'not zero'],
59 'death_in_eval.plx' => [0, 0],
60 'require.plx' => [0, 0],
64 print "1..".keys(%Tests)."\n";
66 eval { require POSIX; &POSIX::WEXITSTATUS(0) };
68 *exitstatus = sub { $_[0] >> 8 };
71 *exitstatus = sub { POSIX::WEXITSTATUS($_[0]) }
75 my $lib = File::Spec->catdir(qw(lib Test Simple sample_tests));
76 while( my($test_name, $exit_codes) = each %Tests ) {
77 my($exit_code) = $exit_codes->[$IsVMS ? 1 : 0];
82 # VMS can't use its own $^X in a system call until almost 5.8
83 $Perl = "MCR $^X" if $] < 5.007003;
85 # Quiet noisy 'SYS$ABORT'. 'hushed' only exists in 5.6 and up,
86 # but it doesn't do any harm on eariler perls.
87 $Perl .= q{ -"Mvmsish=hushed"};
90 my $file = File::Spec->catfile($lib, $test_name);
91 my $wait_stat = system(qq{$Perl -"I../blib/lib" -"I../lib" -"I../t/lib" $file});
92 my $actual_exit = exitstatus($wait_stat);
94 if( $exit_code eq 'not zero' ) {
95 My::Test::ok( $actual_exit != 0,
96 "$test_name exited with $actual_exit ".
97 "(expected $exit_code)");
100 My::Test::ok( $actual_exit == $exit_code,
101 "$test_name exited with $actual_exit ".
102 "(expected $exit_code)");