1 # Can't use Test.pm, that's a 5.005 thing.
5 if( $ENV{PERL_CORE} ) {
11 unless( eval { require File::Spec } ) {
12 print "1..0 # Skip Need File::Spec to run this test\n";
16 if( $^O eq 'VMS' && $] <= 5.00503 ) {
17 print "1..0 # Skip test will hang on older VMS perls\n";
21 if( $^O eq 'MacOS' ) {
22 print "1..0 # Skip exit status broken on Mac OS\n";
27 # Utility testing functions.
29 my($test, $name) = @_;
31 $ok .= "not " unless $test;
32 $ok .= "ok $test_num";
33 $ok .= " - $name" if defined $name;
42 my $IsVMS = $^O eq 'VMS';
44 print "# Ahh! I see you're running VMS.\n" if $IsVMS;
48 'success.plx' => [0, 0],
49 'one_fail.plx' => [1, 4],
50 'two_fail.plx' => [2, 4],
51 'five_fail.plx' => [5, 4],
52 'extras.plx' => [3, 4],
53 'too_few.plx' => [4, 4],
54 'death.plx' => [255, 4],
55 'last_minute_death.plx' => [255, 4],
56 'death_in_eval.plx' => [0, 0],
57 'require.plx' => [0, 0],
60 print "1..".keys(%Tests)."\n";
62 eval { require POSIX; &POSIX::WEXITSTATUS(0) };
64 *exitstatus = sub { $_[0] >> 8 };
67 *exitstatus = sub { POSIX::WEXITSTATUS($_[0]) }
71 my $lib = File::Spec->catdir(qw(lib Test Simple sample_tests));
72 while( my($test_name, $exit_codes) = each %Tests ) {
73 my($exit_code) = $exit_codes->[$IsVMS ? 1 : 0];
78 # VMS can't use its own $^X in a system call until almost 5.8
79 $Perl = "MCR $^X" if $] < 5.007003;
81 # Quiet noisy 'SYS$ABORT'. 'hushed' only exists in 5.6 and up,
82 # but it doesn't do any harm on eariler perls.
83 $Perl .= q{ -"Mvmsish=hushed"};
86 my $file = File::Spec->catfile($lib, $test_name);
87 my $wait_stat = system(qq{$Perl -"I../blib/lib" -"I../lib" -"I../t/lib" $file});
88 my $actual_exit = exitstatus($wait_stat);
90 My::Test::ok( $actual_exit == $exit_code,
91 "$test_name exited with $actual_exit (expected $exit_code)");