Commit | Line | Data |
4dd974da |
1 | # Can't use Test.pm, that's a 5.005 thing. |
2 | package My::Test; |
3 | |
a9153838 |
4 | BEGIN { |
5 | if( $ENV{PERL_CORE} ) { |
6 | chdir 't'; |
7 | @INC = '../lib'; |
8 | } |
9 | } |
10 | |
33459055 |
11 | unless( eval { require File::Spec } ) { |
12 | print "1..0 # Skip Need File::Spec to run this test\n"; |
a9153838 |
13 | exit 0; |
14 | } |
15 | |
16 | if( $^O eq 'VMS' && $] <= 5.00503 ) { |
17 | print "1..0 # Skip test will hang on older VMS perls\n"; |
18 | exit 0; |
33459055 |
19 | } |
0cd946aa |
20 | |
4dd974da |
21 | my $test_num = 1; |
22 | # Utility testing functions. |
23 | sub ok ($;$) { |
24 | my($test, $name) = @_; |
11ea77c5 |
25 | my $ok = ''; |
26 | $ok .= "not " unless $test; |
27 | $ok .= "ok $test_num"; |
28 | $ok .= " - $name" if defined $name; |
29 | $ok .= "\n"; |
30 | print $ok; |
4dd974da |
31 | $test_num++; |
32 | } |
33 | |
34 | |
35 | package main; |
36 | |
d020a79a |
37 | my $IsVMS = $^O eq 'VMS'; |
38 | |
39 | print "# Ahh! I see you're running VMS.\n" if $IsVMS; |
40 | |
4dd974da |
41 | my %Tests = ( |
d020a79a |
42 | # Everyone Else VMS |
43 | 'success.plx' => [0, 0], |
44 | 'one_fail.plx' => [1, 4], |
45 | 'two_fail.plx' => [2, 4], |
46 | 'five_fail.plx' => [5, 4], |
47 | 'extras.plx' => [3, 4], |
48 | 'too_few.plx' => [4, 4], |
49 | 'death.plx' => [255, 4], |
50 | 'last_minute_death.plx' => [255, 4], |
51 | 'death_in_eval.plx' => [0, 0], |
52 | 'require.plx' => [0, 0], |
4dd974da |
53 | ); |
54 | |
55 | print "1..".keys(%Tests)."\n"; |
56 | |
89c1e84a |
57 | eval { require POSIX; &POSIX::WEXITSTATUS(0) }; |
58 | if( $@ ) { |
59 | *exitstatus = sub { $_[0] >> 8 }; |
60 | } |
61 | else { |
62 | *exitstatus = sub { POSIX::WEXITSTATUS($_[0]) } |
63 | } |
64 | |
a9153838 |
65 | chdir 't'; |
0cd946aa |
66 | my $lib = File::Spec->catdir(qw(lib Test Simple sample_tests)); |
d020a79a |
67 | while( my($test_name, $exit_codes) = each %Tests ) { |
68 | my($exit_code) = $exit_codes->[$IsVMS ? 1 : 0]; |
12b8e1e4 |
69 | |
a9153838 |
70 | my $Perl = $^X; |
71 | |
72 | if( $^O eq 'VMS' ) { |
73 | # VMS can't use its own $^X in a system call until almost 5.8 |
74 | $Perl = "MCR $^X" if $] < 5.007003; |
75 | |
76 | # Quiet noisy 'SYS$ABORT'. 'hushed' only exists in 5.6 and up, |
77 | # but it doesn't do any harm on eariler perls. |
78 | $Perl .= q{ -"Mvmsish=hushed"}; |
79 | } |
80 | |
15db8fc4 |
81 | my $file = File::Spec->catfile($lib, $test_name); |
a9153838 |
82 | my $wait_stat = system(qq{$Perl -"I../blib/lib" -"I../lib" -"I../t/lib" $file}); |
89c1e84a |
83 | my $actual_exit = exitstatus($wait_stat); |
12b8e1e4 |
84 | |
d020a79a |
85 | My::Test::ok( $actual_exit == $exit_code, |
86 | "$test_name exited with $actual_exit (expected $exit_code)"); |
87 | } |