Change 13799 by jhi@alpha on 2001/12/19 13:51:37

        Subject: [PATCH lib/lib_pm.PL lib/lib.t] portability snag
        From: Michael G Schwern <[EMAIL PROTECTED]> 
        Date: Wed, 19 Dec 2001 07:42:54 -0500
        Message-ID: <20011219124254.GF8630@blackrider>

Affected files ...

.... //depot/perl/MANIFEST#677 edit
.... //depot/perl/lib/lib.t#1 add
.... //depot/perl/lib/lib_pm.PL#5 edit

Differences ...

==== //depot/perl/MANIFEST#677 (text) ====
Index: perl/MANIFEST
--- perl/MANIFEST.~1~   Wed Dec 19 07:00:05 2001
+++ perl/MANIFEST       Wed Dec 19 07:00:05 2001
@@ -1045,6 +1045,7 @@
 lib/less.pm                    For "use less"
 lib/less.t                     See if less support works
 lib/lib_pm.PL                  For "use lib", produces lib/lib.pm
+lib/lib.t                      For "use lib" testing
 lib/locale.pm                  For "use locale"
 lib/locale.t                   See if locale support works
 lib/Locale/Codes/t/all.t       See if Locale::Codes work

==== //depot/perl/lib/lib_pm.PL#5 (text) ====
Index: perl/lib/lib_pm.PL
--- perl/lib/lib_pm.PL.~1~      Wed Dec 19 07:00:05 2001
+++ perl/lib/lib_pm.PL  Wed Dec 19 07:00:05 2001
@@ -171,6 +171,15 @@
 
     @INC = @lib::ORIG_INC;
 
+=head1 CAVEATS
+
+In order to keep lib.pm small and simple, it only works with Unix
+filepaths.  This doesn't mean it only works on Unix, but non-Unix
+users must first translate their file paths to Unix conventions.
+
+    # VMS users wanting to put [.stuff.moo] into 
+    # their @INC would write
+    use lib 'stuff/moo';
 
 =head1 SEE ALSO
 

==== //depot/perl/lib/lib.t#1 (text) ====
Index: perl/lib/lib.t
--- perl/lib/lib.t.~1~  Wed Dec 19 07:00:05 2001
+++ perl/lib/lib.t      Wed Dec 19 07:00:05 2001
@@ -0,0 +1,75 @@
+#!./perl -w
+
+BEGIN {
+    chdir 't';
+    @INC = '../lib';
+    @OrigINC = @INC;
+}
+
+use Test::More tests => 12;
+use Config;
+use File::Spec;
+use File::Path;
+
+#set up files and directories
+my @lib_dir;
+my $Lib_Dir;
+my $Arch_Dir;
+my $Auto_Dir;
+my $Module;
+BEGIN {
+    # lib.pm is documented to only work with Unix filepaths.
+    @lib_dir  = qw(stuff moo);
+    $Lib_Dir  = join "/", @lib_dir;
+    $Arch_Dir = join "/", @lib_dir, $Config{archname};
+
+    # create the auto/ directory and a module
+    $Auto_Dir = File::Spec->catdir(@lib_dir, $Config{archname},'auto');
+    $Module   = File::Spec->catfile(@lib_dir, 'Yup.pm');
+
+    mkpath [$Auto_Dir];
+
+    open(MOD, ">$Module") || DIE $!;
+    print MOD <<'MODULE';
+package Yup;
+$Plan = 9;
+return '42';
+MODULE
+
+    close MOD;
+}
+
+END {
+    # cleanup the auto/ directory we created.
+    rmtree([$lib_dir[0]]);
+}
+
+
+use lib $Lib_Dir;
+use lib $Lib_Dir;
+
+BEGIN { use_ok('Yup') }
+
+BEGIN {
+    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' );
+
+    is( eval { do 'Yup.pm'  }, 42,  'do() works' );
+    ok( eval { require Yup; },      '   require()' );
+    ok( eval "use Yup; 1;",         '   use()' );
+    is( $@, '' );
+
+    is_deeply(\@OrigINC, \@lib::ORIG_INC,    '@lib::ORIG_INC' );
+}
+
+no lib $Lib_Dir;
+
+BEGIN {
+    is( grep(/stuff/, @INC), 0, 'no lib' );
+    ok( !do 'Yup.pm',           '   do() effected' );
+}
End of Patch.

Reply via email to