Greetings,

We currently have a test failure for vmsish.t # 25 that looks like:

# UTC: 11 48 8 11 5 103 3 161 0
# VMS: 11 48 12 11 5 103 3 161 0
not ok 25 - (stat) UTC:   VMS:
# Failed at lib/vmsish.t;1 line 153

The following patch fixes the test failure:

--- lib/vmsish.t;1      Wed Mar 26 20:31:42 2003
+++ lib/vmsish.t  Tue Jun 10 15:43:33 2003
@@ -112,6 +112,19 @@
     eval "END { \$ENV{'SYS\$TIMEZONE_DIFFERENTIAL'} = $oldtz; }";
     gmtime(0); # Force reset of tz offset
   }
+  # This test script might have been invoked in at least one of four different ways:
+  #     perl lib/vmsish.t
+  #     perl [.lib]vmsish.t
+  #     set def [.t] && perl ../lib/vmsish.t
+  #     set def [.t] && perl [-.lib]vmsish.t
+  # In the following we attempt to find ourselves without resorting to VMS::Filespec.
+  # Note that the chdir in the BEGIN block above complicates matters.
+  my $self = $0;
+  if ( ! -e $self && -e "../$0" ) { $self = "../$0"; }
+  if ( ! -e "$self" ) {
+      $self =~ s/\[//;
+      $self = "[-$self";
+  }
   {
      use_ok('vmsish qw(time)');

@@ -121,12 +134,12 @@
      $vmstime   = time;
      @vmslocal  = localtime($vmstime);
      @vmsgmtime = gmtime($vmstime);
-     $vmsmtime  = (stat $0)[9];
+     $vmsmtime  = (stat "$self")[9];
   }
   $utctime   = time;
   @utclocal  = localtime($vmstime);
   @utcgmtime = gmtime($vmstime);
-  $utcmtime  = (stat $0)[9];
+  $utcmtime  = (stat "$self")[9];

   $offset = $ENV{'SYS$TIMEZONE_DIFFERENTIAL'};
 End of Patch.

I include that also as an attachment so as to better
get around this email client line wrappering trouble:

(See attached file: vmsish_again.patch)

For folks who might be worried that we are papering
over a problem with the $0 behavior I note the following
results on VMS:

$ type [.lib]d0_0.t
# d0_0.t check value of $0 with no chdir calls at all
print "\$0 has value '$0'.\n";

$ type [.lib]d0_1.t
# d0_1.t check value of $0 with chdir call that are not in a BEGIN{} block
chdir 't' if -d 't';
print "\$0 has value '$0'.\n";

$ type [.lib]d0_2.t
# d0_2.t check value of $0 with chdir call that is in a BEGIN{} block
BEGIN {
    chdir 't' if -d 't';
}
print "\$0 has value '$0'.\n";

$ perl lib/d0_0.t
$0 has value 'lib/d0_0.t'.
$ perl lib/d0_1.t
$0 has value 'lib/d0_1.t'.
$ perl lib/d0_2.t
$0 has value 'lib/d0_2.t'.
$ perl [.lib]d0_0.t
$0 has value '[.lib]d0_0.t'.
$ perl [.lib]d0_1.t
$0 has value '[.lib]d0_1.t'.
$ perl [.lib]d0_2.t
$0 has value '[.lib]d0_2.t'.

Contrasted with identical results on linux (as compared
to the unixy script invokations on VMS):

% ./perl lib/d0_0.t
$0 has value 'lib/d0_0.t'.
% ./perl lib/d0_1.t
$0 has value 'lib/d0_1.t'.
% ./perl lib/d0_2.t
$0 has value 'lib/d0_2.t'.

Hence, whatever "problem" there is with the value of $0
in the face of calls to chdir() it is there on both linux
and VMS.  The above patch works around the problem
so as to let the test pass and is a legitimate fix to allow perl's
stat() call to work on an existing file.  If the $0 "problem" is to
be considered a bug this vmsish.t test is not the place to
be testing for the bug, IMO.  Whether or not it is a bug is
certainly debatable.

Peter Prymmer

Attachment: vmsish_again.patch
Description: Binary data

Reply via email to