In perl.git, the branch ap/baseincguard has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/5cbe1046ee6a5f67d00df1f2d8f475421e1f5190?hp=b32130dfcea89a831f277af49073a16519ea28c3>

  discards  b32130dfcea89a831f277af49073a16519ea28c3 (commit)
  discards  03aadc0d86f9afba4faf140d65d08b090142b974 (commit)
  discards  ae30b59e4e3e9bf74a7a47d0f6ac06f88e998207 (commit)
  discards  13122809b8c18970821f0e3d958e361c6915057d (commit)
  discards  dadaf6aa38f5d5807469e722e1ae099a20a7e9c6 (commit)
- Log -----------------------------------------------------------------
commit 5cbe1046ee6a5f67d00df1f2d8f475421e1f5190
Author: Aristotle Pagaltzis <[email protected]>
Date:   Sat Oct 29 09:14:07 2016 +0200

    base: only hide $INC[-1] . from optional loads
-----------------------------------------------------------------------

Summary of changes:
 dist/base/t/incdot.t                               | 36 +++++++++++-----------
 dist/base/t/lib/BaseIncDoubleExtender.pm           | 12 --------
 dist/base/t/lib/BaseIncExtender.pm                 | 10 ------
 .../lib/{BaseIncChecker.pm => BaseIncMandatory.pm} |  2 +-
 dist/base/t/lib/BaseIncOptional.pm                 | 15 +++++++++
 5 files changed, 34 insertions(+), 41 deletions(-)
 delete mode 100644 dist/base/t/lib/BaseIncDoubleExtender.pm
 delete mode 100644 dist/base/t/lib/BaseIncExtender.pm
 rename dist/base/t/lib/{BaseIncChecker.pm => BaseIncMandatory.pm} (88%)
 create mode 100644 dist/base/t/lib/BaseIncOptional.pm

diff --git a/dist/base/t/incdot.t b/dist/base/t/incdot.t
index df98f72223..38d9eb7a29 100644
--- a/dist/base/t/incdot.t
+++ b/dist/base/t/incdot.t
@@ -1,15 +1,24 @@
 #!/usr/bin/perl -w
 
 use strict;
-use Test::More tests => 11; # two extra tests in each BaseInc*.pm
 
-sub rendered_comparison {
+#######################################################################
+
+sub array_diff {
     my ( $got, $expected ) = @_;
     push @$got,      ( '(missing)' )          x ( @$expected - @$got ) if 
@$got < @$expected;
     push @$expected, ( '(should not exist)' ) x ( @$got - @$expected ) if 
@$got > @$expected;
-    join "\n", map +( "got  [$_] " . $got->[$_], 'expected'.(' ' x 
length).$expected->[$_] ), 0 .. $#$got;
+    join "\n    ", '  All differences:', (
+        map +( "got  [$_] " . $got->[$_], 'expected'.(' ' x 
length).$expected->[$_] ),
+        grep $got->[$_] ne $expected->[$_],
+        0 .. $#$got
+    );
 }
 
+#######################################################################
+
+use Test::More tests => 10;  # some extra tests in t/lib/BaseInc*
+
 use lib 't/lib', sub {()};
 
 # make it look like an older perl
@@ -17,32 +26,23 @@ BEGIN { push @INC, '.' if $INC[-1] ne '.' }
 
 my @expected; BEGIN { @expected = @INC }
 
-use base 'BaseIncChecker';
+use base 'BaseIncMandatory';
 
 BEGIN {
     @t::lib::Dummy::ISA = (); # make it look like an optional load
     my $success = eval q{use base 't::lib::Dummy'}, my $err = $@;
     ok !$success, 'loading optional modules from . fails';
     is_deeply \@INC, \@expected, '... without changes to @INC'
-        or diag rendered_comparison [@INC], [@expected];
+        or diag array_diff [@INC], [@expected];
     like $err, qr!Base class package "t::lib::Dummy" is not empty but 
"t/lib/Dummy\.pm" exists in the current directory\.!,
         '... and the proper error message';
 }
 
-BEGIN { @BaseIncExtender::ISA = () } # make it look like an optional load
-use base 'BaseIncExtender';
-
-BEGIN {
-    unshift @expected, 't/lib/blahblah';
-    is_deeply \@INC, \@expected, 'modules loaded by base can prepend entries 
to @INC'
-        or diag rendered_comparison [@INC], [@expected];
-}
-
-BEGIN { @BaseIncDoubleExtender::ISA = () } # make it look like an optional load
-use base 'BaseIncDoubleExtender';
+BEGIN { @BaseIncOptional::ISA = () } # make it look like an optional load
+use base 'BaseIncOptional';
 
 BEGIN {
-    @expected = ( 't/lib/blahdeblah', @expected, 't/lib/on-end' );
+    @expected = ( 't/lib/on-head', @expected, 't/lib/on-tail' );
     is_deeply \@INC, \@expected, 'modules loaded by base can extend @INC at 
both ends'
-        or diag rendered_comparison [@INC], [@expected];
+        or diag array_diff [@INC], [@expected];
 }
diff --git a/dist/base/t/lib/BaseIncDoubleExtender.pm 
b/dist/base/t/lib/BaseIncDoubleExtender.pm
deleted file mode 100644
index 7240d52a2a..0000000000
--- a/dist/base/t/lib/BaseIncDoubleExtender.pm
+++ /dev/null
@@ -1,12 +0,0 @@
-package BaseIncDoubleExtender;
-
-BEGIN { package main;
-    is $INC[-1], '.', 'trailing dot remains in @INC during optional module 
load from base';
-    is 0+(grep ref eq 'CODE', @INC), 3, '... but the expected extra hooks';
-}
-
-use lib 't/lib/blahdeblah';
-
-push @INC, 't/lib/on-end';
-
-1;
diff --git a/dist/base/t/lib/BaseIncExtender.pm 
b/dist/base/t/lib/BaseIncExtender.pm
deleted file mode 100644
index 2679e5d2d1..0000000000
--- a/dist/base/t/lib/BaseIncExtender.pm
+++ /dev/null
@@ -1,10 +0,0 @@
-package BaseIncExtender;
-
-BEGIN { package main;
-    is $INC[-1], '.', 'trailing dot remains in @INC during optional module 
load from base';
-    is 0+(grep ref eq 'CODE', @INC), 3, '... but the expected extra hooks';
-}
-
-use lib 't/lib/blahblah';
-
-1;
diff --git a/dist/base/t/lib/BaseIncChecker.pm 
b/dist/base/t/lib/BaseIncMandatory.pm
similarity index 88%
rename from dist/base/t/lib/BaseIncChecker.pm
rename to dist/base/t/lib/BaseIncMandatory.pm
index be22f26b06..cc299eeb0d 100644
--- a/dist/base/t/lib/BaseIncChecker.pm
+++ b/dist/base/t/lib/BaseIncMandatory.pm
@@ -1,4 +1,4 @@
-package BaseIncChecker;
+package BaseIncMandatory;
 
 BEGIN { package main;
     is $INC[-1], '.', 'trailing dot remains in @INC during mandatory module 
load from base';
diff --git a/dist/base/t/lib/BaseIncOptional.pm 
b/dist/base/t/lib/BaseIncOptional.pm
new file mode 100644
index 0000000000..50f30464c9
--- /dev/null
+++ b/dist/base/t/lib/BaseIncOptional.pm
@@ -0,0 +1,15 @@
+package BaseIncOptional;
+
+BEGIN { package main;
+    is $INC[-1], '.', 'trailing dot remains in @INC during optional module 
load from base';
+    is 0+(grep ref eq 'CODE', @INC), 3, '... but the expected extra hooks';
+    delete $INC{'t/lib/Dummy.pm'};
+    ok eval('require t::lib::Dummy'), '... however they do not prevent loading 
modules from .' or diag "$@";
+    isnt 0+(grep ref eq 'CODE', @INC), 3, '... which auto-removes the 
dot-hiding hook';
+}
+
+use lib 't/lib/on-head';
+
+push @INC, 't/lib/on-tail';
+
+1;

--
Perl5 Master Repository

Reply via email to