At 06:37 AM 8/28/2001 -0400, Michael G Schwern wrote:
>On Mon, Aug 27, 2001 at 10:51:40PM -0500, Craig A. Berry wrote:
>> Thanks for bearing with us on this.  I think that should probably be:
>> 
>> 1.) 0, the generic success value
>> 2.) 1, the generic failure value
>> 3.) Any failure status that is not the same severity as generic
>> failure; I'd say 2 would do as well as anything.  The following may
>> be helpful:
>
>Ok, try this:
>
>http://www.pobox.com/~schwern/src/Test-Simple-0.15.tar.gz

Well, we're still hosed and I steered you wrong because I forgot you were 
doing this by setting $? in an END block.  From L<perlvms/$?>:

====
when setting C<$?> in
an END block, an attempt is made to convert the POSIX value
into a native status intelligible to the operating system upon
exiting Perl.  What this boils down to is that setting C<$?>
to zero results in the generic success value SS$_NORMAL, and
setting C<$?> to a non-zero value results in the generic
failure status SS$_ABORT.
====

So, setting $? to a value doesn't do the same thing as exiting with that 
value, as the following example illustrates:

$ perl -e "exit 2;"
%NONAME-E-NOMSG, Message number 00000002
$ show symbol $status
  $STATUS == "%X00000002"
$ perl -e "END {$?=2;}"
%SYSTEM-F-ABORT, abort
$ sh symbol $status
  $STATUS == "%X0000002C"

This behavior can be overridden by the "use vmsish 'status'" pragma but 
that's not available on other platforms and can't be conditionalized because 
it does its thing at compile time.  And as I understand it, you have to use 
$? rather than exit() because the latter misbehaves when called in an END 
block.

I think we're pretty much stuck with thumbs up or thumbs down, and no 
gradations thereof, which is darn annoying considering that with native 
condition values you get a couple billion flavors of success and failure.  
Does anyone have any better ideas?

Also, does anyone object to moving the vmsish pragmas over to [.ext] where 
they'd be available on all platforms and then just have them be noops on 
other platforms?  That could help us with these situations in the future.

The following gets us passing all tests in this dumbed down version:

--- lib/Test/Simple.pm;-0       Tue Aug 28 05:23:15 2001
+++ lib/Test/Simple.pm  Tue Aug 28 13:05:31 2001
@@ -304,10 +304,9 @@
   my $code = $_[0];
 
   if( $IsVMS ) {
-      # VMS exit codes don't work like the rest of the universe.
-      $? = $code == 0   ? 0 :   # Success -> 0
-           $code == 255 ? 2 :   # Abort   -> 2
-                          1 ;   # Failure -> 1
+      # without vmsish pragmas, $? only records success and failure on VMS
+      $? = $code == 0   ? 0 :   # Success -> 0 (mapped to SS$_NORMAL by C RTL)
+                          1 ;   # Failure (any non-zero value mapped to SS$_ABORT)
   }
   else {
       $? = $code;
--- t/exit.t;-0 Tue Aug 28 05:33:27 2001
+++ t/exit.t    Tue Aug 28 13:06:41 2001
@@ -24,13 +24,13 @@
 my %Tests = (
              #                      Everyone Else   VMS
              'success.plx'              => [0,      0],
-             'one_fail.plx'             => [1,      1],
-             'two_fail.plx'             => [2,      1],
-             'five_fail.plx'            => [5,      1],
-             'extras.plx'               => [3,      1],
-             'too_few.plx'              => [4,      1],
-             'death.plx'                => [255,    2],
-             'last_minute_death.plx'    => [255,    2],
+             'one_fail.plx'             => [1,      4], # 4 = severity bits of 
+SS$_ABORT
+             'two_fail.plx'             => [2,      4],
+             'five_fail.plx'            => [5,      4],
+             'extras.plx'               => [3,      4],
+             'too_few.plx'              => [4,      4],
+             'death.plx'                => [255,    4],
+             'last_minute_death.plx'    => [255,    4],
              'death_in_eval.plx'        => [0,      0],
              'require.plx'              => [0,      0],
             );
[end of patch]


Reply via email to