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";
28 require Test::Builder;
29 my $TB = Test::Builder->create();
35 my $IsVMS = $^O eq 'VMS';
37 print "# Ahh! I see you're running VMS.\n" if $IsVMS;
41 'success.plx' => [0, 0],
42 'one_fail.plx' => [1, 4],
43 'two_fail.plx' => [2, 4],
44 'five_fail.plx' => [5, 4],
45 'extras.plx' => [2, 4],
46 'too_few.plx' => [255, 4],
47 'too_few_fail.plx' => [2, 4],
48 'death.plx' => [255, 4],
49 'last_minute_death.plx' => [255, 4],
50 'pre_plan_death.plx' => ['not zero', 'not zero'],
51 'death_in_eval.plx' => [0, 0],
52 'require.plx' => [0, 0],
53 'death_with_handler.plx' => [255, 4],
57 $TB->plan( tests => scalar keys(%Tests) );
59 eval { require POSIX; &POSIX::WEXITSTATUS(0) };
61 *exitstatus = sub { $_[0] >> 8 };
64 *exitstatus = sub { POSIX::WEXITSTATUS($_[0]) }
68 my $lib = File::Spec->catdir(qw(lib Test Simple sample_tests));
69 while( my($test_name, $exit_codes) = each %Tests ) {
70 my($exit_code) = $exit_codes->[$IsVMS ? 1 : 0];
75 # VMS can't use its own $^X in a system call until almost 5.8
76 $Perl = "MCR $^X" if $] < 5.007003;
78 # Quiet noisy 'SYS$ABORT'. 'hushed' only exists in 5.6 and up,
79 # but it doesn't do any harm on eariler perls.
80 $Perl .= q{ -"Mvmsish=hushed"};
83 my $file = File::Spec->catfile($lib, $test_name);
84 my $wait_stat = system(qq{$Perl -"I../blib/lib" -"I../lib" -"I../t/lib" $file});
85 my $actual_exit = exitstatus($wait_stat);
87 if( $exit_code eq 'not zero' ) {
88 $TB->isnt_num( $actual_exit, 0,
89 "$test_name exited with $actual_exit ".
90 "(expected $exit_code)");
93 $TB->is_num( $actual_exit, $exit_code,
94 "$test_name exited with $actual_exit ".
95 "(expected $exit_code)");