This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[PATCH] Syncing with Test::Simple 0.19
[perl5.git] / lib / Test / Simple / t / exit.t
CommitLineData
15db8fc4
JH
1BEGIN {
2 chdir 't' if -d 't';
3 @INC = '../lib';
15db8fc4
JH
4}
5
4dd974da
JH
6# Can't use Test.pm, that's a 5.005 thing.
7package My::Test;
8
0cd946aa
MS
9use File::Spec;
10
4dd974da
JH
11my $test_num = 1;
12# Utility testing functions.
13sub ok ($;$) {
14 my($test, $name) = @_;
11ea77c5
JH
15 my $ok = '';
16 $ok .= "not " unless $test;
17 $ok .= "ok $test_num";
18 $ok .= " - $name" if defined $name;
19 $ok .= "\n";
20 print $ok;
4dd974da
JH
21 $test_num++;
22}
23
24
25package main;
26
d020a79a
JH
27my $IsVMS = $^O eq 'VMS';
28
29print "# Ahh! I see you're running VMS.\n" if $IsVMS;
30
4dd974da 31my %Tests = (
d020a79a
JH
32 # Everyone Else VMS
33 'success.plx' => [0, 0],
34 'one_fail.plx' => [1, 4],
35 'two_fail.plx' => [2, 4],
36 'five_fail.plx' => [5, 4],
37 'extras.plx' => [3, 4],
38 'too_few.plx' => [4, 4],
39 'death.plx' => [255, 4],
40 'last_minute_death.plx' => [255, 4],
41 'death_in_eval.plx' => [0, 0],
42 'require.plx' => [0, 0],
4dd974da
JH
43 );
44
45print "1..".keys(%Tests)."\n";
46
0cd946aa 47my $lib = File::Spec->catdir(qw(lib Test Simple sample_tests));
d020a79a
JH
48while( my($test_name, $exit_codes) = each %Tests ) {
49 my($exit_code) = $exit_codes->[$IsVMS ? 1 : 0];
12b8e1e4 50
15db8fc4 51 my $file = File::Spec->catfile($lib, $test_name);
15db8fc4 52 my $wait_stat = system(qq{$^X -"I../lib" -"I../t/lib" $file});
d020a79a 53 my $actual_exit = $wait_stat >> 8;
12b8e1e4 54
d020a79a
JH
55 My::Test::ok( $actual_exit == $exit_code,
56 "$test_name exited with $actual_exit (expected $exit_code)");
57}