Front page | perl.perl5.porters |
Postings from July 2001
Re: new exit tests on VMS
Thread Previous
|
Thread Next
From:
Craig A. Berry
Date:
July 31, 2001 11:25
Subject:
Re: new exit tests on VMS
Message ID:
5.1.0.14.0.20010731114845.03743008@mail.telocity.com
At 12:16 AM 7/31/2001 -0400, Michael G Schwern wrote:
>On Mon, Jul 30, 2001 at 04:47:36PM -0500, Craig A. Berry wrote:
>> Essentially it looks like the only thing that's portable is that 0 means
>> success and anything non-zero means an error.
>
>That's the big issue here. Should exit codes on vmsperl be the same
>as in Unix, or does it make more sense for VMS to do its own thing?
>
>What should this print?
>
> system(q{perl -e "exit 42"});
> print $? >> 8;
>
>42 on Unix, what on VMS?
2, it turns out. Here are the warning, error, and fatal error flavors of
the abort status (which you landed on by chance), which return 1, 2, and 4
respectively:
$ perl -e "system('perl -e ""exit 40;""'); print $? >> 8;"
%SYSTEM-W-ABORT, abort
1
$ perl -e "system('perl -e ""exit 42;""'); print $? >> 8;"
%SYSTEM-E-ABORT, abort
2
$ perl -e "system('perl -e ""exit 44;""'); print $? >> 8;"
%SYSTEM-F-ABORT, abort
4
Odd numbers always indicate success so system() returns zero. The following
may be considered a patch if you wish since all the new tests pass, though
this may or may not be the appropriate place to do them. I'll try to have a
look at lib/Test/Simple/t/simple.t as well.
$? in an END block still doesn't work and may be genuinely broken on VMS (or
just never implemented); any idea where in the sources I would look to see
where this is done?
--- t/run/exit.t;-0 Mon Jul 9 09:11:31 2001
+++ t/run/exit.t Tue Jul 31 12:01:03 2001
@@ -18,15 +18,41 @@
return system($cmd.$quote.$code.$quote);
}
-use Test::More tests => 3;
+## can't use this in 'use Test::More' yet
+##my $numtests = ($^O eq 'VMS') ? 7 : 3;
-my $exit;
+use Test::More tests => 'no_plan';
+
+my $exit, $exit_arg;
$exit = run('exit');
is( $exit >> 8, 0, 'Normal exit' );
-$exit = run('exit 42');
-is( $exit >> 8, 42, 'Non-zero exit' );
+if ($^O ne 'VMS') {
+
+ $exit = run('exit 42');
+ is( $exit >> 8, 42, 'Non-zero exit' );
+
+} else {
+
+# On VMS, successful returns from system() are always 0, warnings are 1,
+# errors are 2, and fatal errors are 4.
+
+ $exit = run("exit 196609"); # %CLI-S-NORMAL
+ is( $exit >> 8, 0, 'success exit' );
+
+ $exit = run("exit 196611"); # %CLI-I-NORMAL
+ is( $exit >> 8, 0, 'informational exit' );
+
+ $exit = run("exit 196608"); # %CLI-W-NORMAL
+ is( $exit >> 8, 1, 'warning exit' );
+
+ $exit = run("exit 196610"); # %CLI-E-NORMAL
+ is( $exit >> 8, 2, 'error exit' );
+
+ $exit = run("exit 196612"); # %CLI-F-NORMAL
+ is( $exit >> 8, 4, 'fatal error exit' );
+}
$exit = run('END { $? = 42 }');
is( $exit >> 8, 42, 'Changing $? in END block' );
[end of patch]
Thread Previous
|
Thread Next