This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Big MacPerl Testing Patch No. 2
authorChris Nandor <pudge@pobox.com>
Fri, 31 May 2002 16:07:35 +0000 (16:07 +0000)
committerChris Nandor <pudge@pobox.com>
Fri, 31 May 2002 16:07:35 +0000 (16:07 +0000)
There might be more soon, but this is almost all of it for now

p4raw-id: //depot/macperl@16926

14 files changed:
ext/DynaLoader/DynaLoader_pm.PL
lib/Devel/SelfStubber.pm
lib/Devel/SelfStubber.t
lib/English.t
lib/ExtUtils/t/00setup_dummy.t
lib/ExtUtils/t/Command.t
lib/File/Path.t
lib/File/Temp.pm
lib/FindBin.t
lib/Tie/File/t/09_gen_rs.t
lib/diagnostics.t
lib/lib.t
lib/lib_pm.PL
t/lib/MakeMaker/Test/Utils.pm

index 9fdaf70..c4299c8 100644 (file)
@@ -77,6 +77,9 @@ $Is_VMS    = $^O eq 'VMS';
 $do_expand = $Is_VMS;
 $Is_MacOS  = $^O eq 'MacOS';
 
+my $Mac_FS;
+$Mac_FS = eval { require Mac::FileSpec::Unixish } if $Is_MacOS;
+
 @dl_require_symbols = ();       # names of symbols we need
 @dl_resolve_using   = ();       # names of files to link with
 @dl_library_path    = ();       # path to look for files
@@ -247,6 +250,9 @@ sub bootstrap {
        my $dir;
        if ($Is_MacOS) {
            my $path = $_;
+           if ($Mac_FS) {
+               $path = Mac::FileSpec::Unixish::nativize($path);
+           }
            $path .= ":"  unless /:$/;
            $dir = "${path}auto:$modpname";
        } else {
index baf46dc..bfdb443 100644 (file)
@@ -1,4 +1,5 @@
 package Devel::SelfStubber;
+use File::Spec;
 require SelfLoader;
 @ISA = qw(SelfLoader);
 @EXPORT = 'AUTOLOAD';
@@ -29,10 +30,11 @@ sub _package_defined {
 sub stub {
     my($self,$module,$lib) = @_;
     my($line,$end_data,$fh,$mod_file,$found_selfloader);
-    $lib ||= '.';
+    $lib ||= File::Spec->curdir();
     ($mod_file = $module) =~ s,::,/,g;
+    $mod_file =~ tr|/|:| if $^O eq 'MacOS';
     
-    $mod_file = "$lib/$mod_file.pm";
+    $mod_file = File::Spec->catfile($lib, "$mod_file.pm");
     $fh = "${module}::DATA";
     my (@BEFORE_DATA, @AFTER_DATA, @AFTER_END);
     @DATA = @STUBS = ();
index 2e74a02..b5deb14 100644 (file)
@@ -7,8 +7,10 @@ BEGIN {
 
 use strict;
 use Devel::SelfStubber;
+use File::Spec::Functions;
 
 my $runperl = "$^X \"-I../lib\"";
+$runperl =~ s|../lib|::lib:| if $^O eq 'MacOS';
 
 # ensure correct output ordering for system() calls
 
@@ -31,7 +33,8 @@ push @cleanup, $inlib;
 
 while (<DATA>) {
   if (/^\#{16,}\s+(.*)/) {
-    my $file = "$inlib/$1";
+    my $f = $1;
+    my $file = catfile(curdir(),$inlib,$f);
     push @cleanup, $file;
     open FH, ">$file" or die $!;
   } else {
@@ -169,8 +172,9 @@ $Devel::SelfStubber::JUST_STUBS=0;
 
 undef $/;
 foreach my $module (@module, 'Data', 'End') {
-  my $file = "$lib/$module.pm";
-  open FH, "$inlib/$module.pm" or die $!;
+  my $file = catfile(curdir(),$lib,"$module.pm");
+  my $fileo = catfile(curdir(),$inlib,"$module.pm");
+  open FH, $fileo or die "Can't open $fileo: $!";
   my $contents = <FH>;
   close FH or die $!;
   push @cleanup, $file;
@@ -210,7 +214,7 @@ system "$runperl -w \"-I$lib\" \"-MData\" -e \"Data::ok\"";
 system "$runperl -w \"-I$lib\" \"-MEnd\" -e \"End::lime\"";
 
 # But check that the documentation after the __END__ survived.
-open FH, "$lib/End.pm" or die $!;
+open FH, catfile(curdir(),$lib,"End.pm") or die $!;
 $_ = <FH>;
 close FH or die $!;
 
index 6e11dcc..d04ed23 100755 (executable)
@@ -123,7 +123,7 @@ is( $keys[1], 'd|e|f', '$SUBSCRIPT_SEPARATOR' );
 eval { is( $EXCEPTIONS_BEING_CAUGHT, 1, '$EXCEPTIONS_BEING_CAUGHT' ) };
 ok( !$EXCEPTIONS_BEING_CAUGHT, '$EXCEPTIONS_BEING_CAUGHT should be false' );
 
-eval { open('') };
+eval { local *F; my $f = 'asdasdasd'; ++$f while -e $f; open(F, $f); };
 is( $OS_ERROR, $ERRNO, '$OS_ERROR' );
 ok( $OS_ERROR{ENOENT}, '%OS_ERROR (ENOENT should be set)' );
 
index 3ec1d31..a55fc00 100644 (file)
@@ -12,11 +12,12 @@ chdir 't';
 
 use strict;
 use Test::More tests => 9;
+use File::Spec::Functions;
 use File::Path;
 use File::Basename;
 
 my %Files = (
-             'Big-Dummy/lib/Big/Dummy.pm'     => <<'END',
+             catfile(curdir(),'Big-Dummy','lib','Big','Dummy.pm')     => <<'END',
 package Big::Dummy;
 
 $VERSION = 0.01;
@@ -24,7 +25,7 @@ $VERSION = 0.01;
 1;
 END
 
-             'Big-Dummy/Makefile.PL'          => <<'END',
+             catfile(curdir(),'Big-Dummy','Makefile.PL')          => <<'END',
 use ExtUtils::MakeMaker;
 
 printf "Current package is: %s\n", __PACKAGE__;
@@ -36,14 +37,14 @@ WriteMakefile(
 );
 END
 
-             'Big-Dummy/t/compile.t'          => <<'END',
+             catfile(curdir(),'Big-Dummy','t','compile.t')          => <<'END',
 print "1..2\n";
 
 print eval "use Big::Dummy; 1;" ? "ok 1\n" : "not ok 1\n";
 print "ok 2 - TEST_VERBOSE\n";
 END
 
-             'Big-Dummy/Liar/t/sanity.t'      => <<'END',
+             catfile(curdir(),'Big-Dummy','Liar','t','sanity.t')      => <<'END',
 print "1..3\n";
 
 print eval "use Big::Dummy; 1;" ? "ok 1\n" : "not ok 1\n";
@@ -51,7 +52,7 @@ print eval "use Big::Liar; 1;" ? "ok 2\n" : "not ok 2\n";
 print "ok 3 - TEST_VERBOSE\n";
 END
 
-             'Big-Dummy/Liar/lib/Big/Liar.pm' => <<'END',
+             catfile(curdir(),'Big-Dummy','Liar','lib','Big','Liar.pm') => <<'END',
 package Big::Liar;
 
 $VERSION = 0.01;
@@ -59,7 +60,7 @@ $VERSION = 0.01;
 1;
 END
 
-             'Big-Dummy/Liar/Makefile.PL'     => <<'END',
+             catfile(curdir(),'Big-Dummy','Liar','Makefile.PL')     => <<'END',
 use ExtUtils::MakeMaker;
 
 my $mm = WriteMakefile(
@@ -74,7 +75,7 @@ foreach my $key (qw(INST_LIB INST_ARCHLIB)) {
 }
 END
 
-             'Problem-Module/Makefile.PL'   => <<'END',
+             catfile(curdir(),'Problem-Module','Makefile.PL')   => <<'END',
 use ExtUtils::MakeMaker;
 
 WriteMakefile(
@@ -82,7 +83,7 @@ WriteMakefile(
 );
 END
 
-             'Problem-Module/subdir/Makefile.PL'    => <<'END',
+             catfile(curdir(),'Problem-Module','subdir','Makefile.PL')    => <<'END',
 printf "\@INC %s .\n", (grep { $_ eq '.' } @INC) ? "has" : "doesn't have";
 
 warn "I think I'm going to be sick\n";
index 709f3e1..2e0e08f 100644 (file)
@@ -106,7 +106,8 @@ BEGIN {
 
     SKIP: {
         if ($^O eq 'amigaos' || $^O eq 'os2' || $^O eq 'MSWin32' ||
-            $^O eq 'NetWare' || $^O eq 'dos' || $^O eq 'cygwin') {
+            $^O eq 'NetWare' || $^O eq 'dos' || $^O eq 'cygwin'  ||
+            $^O eq 'MacOS') {
             skip( "different file permission semantics on $^O", 3);
         }
 
index 6e1414e..86b280d 100755 (executable)
@@ -6,6 +6,7 @@ BEGIN {
 }
 
 use File::Path;
+use File::Spec::Functions;
 use strict;
 
 my $count = 0;
@@ -16,10 +17,11 @@ print "1..4\n";
 # first check for stupid permissions second for full, so we clean up
 # behind ourselves
 for my $perm (0111,0777) {
-    mkpath("foo/bar");
-    chmod $perm, "foo", "foo/bar";
+    my $path = catdir(curdir(), "foo", "bar");
+    mkpath($path);
+    chmod $perm, "foo", $path;
 
-    print "not " unless -d "foo" && -d "foo/bar";
+    print "not " unless -d "foo" && -d $path;
     print "ok ", ++$count, "\n";
 
     rmtree("foo");
index 0df1af4..6f351df 100644 (file)
@@ -472,14 +472,14 @@ sub _gettemp {
       if ( $open_success ) {
 
        # Reset umask
-       umask($umask);
+       umask($umask) if defined $umask;
 
        # Opened successfully - return file handle and name
        return ($fh, $path);
 
       } else {
        # Reset umask
-       umask($umask);
+       umask($umask) if defined $umask;
 
        # Error opening file - abort with error
        # if the reason was anything but EEXIST
@@ -503,13 +503,13 @@ sub _gettemp {
       if (mkdir( $path, 0700)) {
        # created okay
        # Reset umask
-       umask($umask);
+       umask($umask) if defined $umask;
 
        return undef, $path;
       } else {
 
        # Reset umask
-       umask($umask);
+       umask($umask) if defined $umask;
 
        # Abort with error if the reason for failure was anything
        # except EEXIST
index ebca15b..80ac811 100755 (executable)
@@ -11,5 +11,9 @@ use FindBin qw($Bin);
 
 print "# $Bin\n";
 
-print "not " unless $Bin =~ m,[/.]lib\]?$,;
+if ($^O eq 'MacOS') {
+    print "not " unless $Bin =~ m,:lib:$,;
+} else {
+    print "not " unless $Bin =~ m,[/.]lib\]?$,;
+}
 print "ok 1\n";
index 7d70e3e..c202556 100644 (file)
@@ -104,6 +104,7 @@ if (setup_badly_terminated_file(3)) {
   $N++;
   push @a, "next";
   check_contents($badrec, "next");
+  undef $o; untie @a;
 }
 # (51-52)
 if (setup_badly_terminated_file(2)) {
@@ -112,6 +113,7 @@ if (setup_badly_terminated_file(2)) {
     or die "Couldn't tie file: $!";
   splice @a, 1, 0, "x", "y";
   check_contents($badrec, "x", "y");
+  undef $o; untie @a;
 }
 # (53-56)
 if (setup_badly_terminated_file(4)) {
@@ -126,6 +128,7 @@ if (setup_badly_terminated_file(4)) {
     : "not ok $N \# expected <$badrec>, got <$r[0]>\n";
   $N++;
   check_contents("x", "y");
+  undef $o; untie @a;
 }
 
 # (57-58) 20020402 The modifiaction would have failed if $\ were set wrong.
@@ -138,6 +141,7 @@ if (setup_badly_terminated_file(2)) {
     my $z = $a[0];
   }
   check_contents($badrec);
+  undef $o; untie @a;
 }
 
 sub setup_badly_terminated_file {
index f30f70e..d9855a9 100644 (file)
@@ -1,8 +1,13 @@
 #!./perl
 
 BEGIN {
-    chdir '..' if -d '../pod' && -d '../t';
-    @INC = 'lib';
+    if ($^O eq 'MacOS') {
+       chdir '::' if -d '::pod' && -d '::t';
+       @INC = ':lib:';
+    } else {
+       chdir '..' if -d '../pod' && -d '../t';
+       @INC = 'lib';
+    }
 }
 
 use Test::More tests => 2;
index 9a86ac7..41280ee 100644 (file)
--- a/lib/lib.t
+++ b/lib/lib.t
@@ -51,13 +51,25 @@ use lib $Lib_Dir;
 BEGIN { use_ok('Yup') }
 
 BEGIN {
+    if ($^O eq 'MacOS') {
+       for ($Lib_Dir, $Arch_Dir) {
+           tr|/|:|;
+           $_ .= ":" unless /:$/;
+           $_ = ":$_" unless /^:/; # we know this path is relative
+       }
+    }
     is( $INC[1], $Lib_Dir,          'lib adding at end of @INC' );
     print "# \@INC == @INC\n";
     is( $INC[0], $Arch_Dir,        '    auto/ dir in front of that' );
     is( grep(/^\Q$Lib_Dir\E$/, @INC), 1,   '    no duplicates' );
 
     # Yes, %INC uses Unixy filepaths.
-    is( $INC{'Yup.pm'}, join("/",$Lib_Dir, 'Yup.pm'),    '%INC set properly' );
+    # Not on Mac OS, it doesn't ... it never has, at least.
+    my $path = join("/",$Lib_Dir, 'Yup.pm');
+    if ($^O eq 'MacOS') {
+       $path = $Lib_Dir . 'Yup.pm';
+    }
+    is( $INC{'Yup.pm'}, $path,    '%INC set properly' );
 
     is( eval { do 'Yup.pm'  }, 42,  'do() works' );
     ok( eval { require Yup; },      '   require()' );
index d778673..d0d9e1e 100644 (file)
@@ -57,6 +57,12 @@ print OUT <<'!NO!SUBS!';
 
 our @ORIG_INC = @INC;  # take a handy copy of 'original' value
 our $VERSION = '0.5564';
+my $Is_MacOS = $^O eq 'MacOS';
+my $Mac_FS;
+if ($Is_MacOS) {
+       require File::Spec;
+       $Mac_FS = eval { require Mac::FileSpec::Unixish };
+}
 
 sub import {
     shift;
@@ -67,21 +73,29 @@ sub import {
            require Carp;
            Carp::carp("Empty compile time value given to use lib");
        }
+
+       $_ = _nativize($_);
+
        if (-e && ! -d _) {
            require Carp;
            Carp::carp("Parameter to use lib must be directory, not file");
        }
        unshift(@INC, $_);
-        # Add any previous version directories we found at configure time
-        foreach my $incver (@inc_version_list)
-        {
-            unshift(@INC, "$_/$incver") if -d "$_/$incver";
-        }
+       # Add any previous version directories we found at configure time
+       foreach my $invcer (@inc_version_list)
+       {
+           my $dir = $Is_MacOS
+               ? File::Spec->catdir( $_, $incver )
+               : "$_/$incver";
+           unshift(@INC, $dir) if -d $dir;
+       }
        # Put a corresponding archlib directory infront of $_ if it
        # looks like $_ has an archlib directory below it.
-       unshift(@INC, "$_/$archname")          if -d "$_/$archname/auto";
-       unshift(@INC, "$_/$version")           if -d "$_/$version";
-       unshift(@INC, "$_/$version/$archname") if -d "$_/$version/$archname";
+       my($arch_auto_dir, $arch_dir, $version_dir, $version_arch_dir)
+           = _get_dirs($_);
+       unshift(@INC, $arch_dir)         if -d $arch_auto_dir;
+       unshift(@INC, $version_dir)      if -d $version_dir;
+       unshift(@INC, $version_arch_dir) if -d $version_arch_dir;
     }
 
     # remove trailing duplicates
@@ -95,10 +109,14 @@ sub unimport {
 
     my %names;
     foreach (@_) {
+       $_ = _nativize($_);
+
+       my($arch_auto_dir, $arch_dir, $version_dir, $version_arch_dir)
+           = _get_dirs($_);
        ++$names{$_};
-       ++$names{"$_/$archname"}          if -d "$_/$archname/auto";
-       ++$names{"$_/$version"}           if -d "$_/$version";
-       ++$names{"$_/$version/$archname"} if -d "$_/$version/$archname";
+       ++$names{$arch_dir}         if -d $arch_auto_dir;
+       ++$names{$version_dir}      if -d $version_dir;
+       ++$names{$version_arch_dir} if -d $version_arch_dir;
     }
 
     # Remove ALL instances of each named directory.
@@ -106,6 +124,37 @@ sub unimport {
     return;
 }
 
+sub _get_dirs {
+    my($dir) = @_;
+    my($arch_auto_dir, $arch_dir, $version_dir, $version_arch_dir);
+
+    # we could use this for all platforms in the future, but leave it
+    # Mac-only for now, until there is more time for testing it.
+    if ($Is_MacOS) {
+       $arch_auto_dir    = File::Spec->catdir( $_, $archname, 'auto' );
+       $arch_dir         = File::Spec->catdir( $_, $archname, );
+       $version_dir      = File::Spec->catdir( $_, $version );
+       $version_arch_dir = File::Spec->catdir( $_, $version, $archname );
+    } else {
+       $arch_auto_dir    = "$_/$archname/auto";
+       $arch_dir         = "$_/$archname";
+       $version_dir      = "$_/$version";
+       $version_arch_dir = "$_/$version/$archname";
+    }
+    return($arch_auto_dir, $arch_dir, $version_dir, $version_arch_dir);
+}
+
+sub _nativize {
+    my($dir) = @_;
+
+    if ($Is_MacOS && $Mac_FS) {
+       $dir = Mac::FileSpec::Unixish::nativize($dir);
+       $dir .= ":" unless $dir =~ /:$/;
+    }
+
+    return $dir;
+}
+
 1;
 __END__
 
@@ -181,6 +230,13 @@ users must first translate their file paths to Unix conventions.
     # their @INC would write
     use lib 'stuff/moo';
 
+=head1 NOTES
+
+In the future, this module will likely use File::Spec for determining
+paths, as it does now for Mac OS (where Unix-style or Mac-style paths
+work, and Unix-style paths are converted properly to Mac-style paths
+before being added to @INC).
+
 =head1 SEE ALSO
 
 FindBin - optional module which deals with paths relative to the source file.
index b7e01ae..fff8055 100644 (file)
@@ -16,6 +16,7 @@ $VERSION = 0.02;
             );
 
 my $Is_VMS = $^O eq 'VMS';
+my $Is_MacOS = $^O eq 'MacOS';
 
 
 =head1 NAME
@@ -68,7 +69,7 @@ sub which_perl {
     $perl .= $Config{exe_ext} unless $perl =~ m/$Config{exe_ext}$/i;
 
     my $perlpath = File::Spec->rel2abs( $perl );
-    unless( -x $perlpath ) {
+    unless( $Is_MacOS || -x $perlpath ) {
         # $^X was probably 'perl'
 
         # When building in the core, *don't* go off and find