In perl.git, the branch ap/baseincguard-old has been updated <http://perl5.git.perl.org/perl.git/commitdiff/aafdbd860d679789a502441ef6149659edcf5e58?hp=81fe29c06e4d088eab2bcdedceee120a27f30c8e>
discards 81fe29c06e4d088eab2bcdedceee120a27f30c8e (commit) discards 03aadc0d86f9afba4faf140d65d08b090142b974 (commit) discards ae30b59e4e3e9bf74a7a47d0f6ac06f88e998207 (commit) discards 13122809b8c18970821f0e3d958e361c6915057d (commit) discards dadaf6aa38f5d5807469e722e1ae099a20a7e9c6 (commit) - Log ----------------------------------------------------------------- commit aafdbd860d679789a502441ef6149659edcf5e58 Author: Aristotle Pagaltzis <[email protected]> Date: Thu Oct 20 17:05:45 2016 +0200 base: only hide $INC[-1] . from optional loads M dist/base/lib/base.pm M dist/base/t/incdot.t M dist/base/t/lib/BaseIncMandatory.pm commit 2a0179bac6ff4e0adb049960def423709b5f813f Author: Aristotle Pagaltzis <[email protected]> Date: Sat Oct 29 02:53:53 2016 +0200 base: test failure of optional module loads from . M dist/base/t/incdot.t commit 9c8b56c2d98bc3ab433a01985bee10cf174191af Author: Aristotle Pagaltzis <[email protected]> Date: Sat Oct 29 02:53:53 2016 +0200 base: make t/incdot.t failures more readable M dist/base/t/incdot.t commit da4c6f1f889e78a591ff1bf872fb683f51b7c7d5 Author: Aristotle Pagaltzis <[email protected]> Date: Sat Oct 29 03:42:37 2016 +0200 base: test that @INC gets the dummy hook M dist/base/t/incdot.t M dist/base/t/lib/BaseIncMandatory.pm M dist/base/t/lib/BaseIncOptional.pm commit 00175f9888a37455c912cfa8162595e1184d516e Author: Aristotle Pagaltzis <[email protected]> Date: Thu Oct 20 16:38:20 2016 +0200 base: fix test name R100 dist/base/t/incmodified-vs-incdot.t dist/base/t/incdot.t commit 5443fe94faec20aa9f63e87c8dcbacbf7e306086 Author: Aristotle Pagaltzis <[email protected]> Date: Thu Oct 20 16:30:51 2016 +0200 base: roll relevant incdot tests together D dist/base/t/incdot.t M dist/base/t/incmodified-vs-incdot.t D dist/base/t/lib/BaseIncDoubleExtender.pm D dist/base/t/lib/BaseIncExtender.pm A dist/base/t/lib/BaseIncMandatory.pm A dist/base/t/lib/BaseIncOptional.pm ----------------------------------------------------------------------- Summary of changes: dist/base/t/incdot.t | 36 +++++++++++----------- dist/base/t/lib/BaseIncDoubleExtender.pm | 12 -------- .../lib/{BaseIncChecker.pm => BaseIncMandatory.pm} | 2 +- .../lib/{BaseIncExtender.pm => BaseIncOptional.pm} | 6 ++-- 4 files changed, 23 insertions(+), 33 deletions(-) delete mode 100644 dist/base/t/lib/BaseIncDoubleExtender.pm rename dist/base/t/lib/{BaseIncChecker.pm => BaseIncMandatory.pm} (88%) rename dist/base/t/lib/{BaseIncExtender.pm => BaseIncOptional.pm} (71%) diff --git a/dist/base/t/incdot.t b/dist/base/t/incdot.t index df98f72223..7cd8c26dd7 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 => 8; # 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 afc3a2b262..0000000000 --- a/dist/base/t/lib/BaseIncDoubleExtender.pm +++ /dev/null @@ -1,12 +0,0 @@ -package BaseIncDoubleExtender; - -BEGIN { package main; - isnt $INC[-1], '.', 'no trailing dot in @INC during optional module load from base'; - is 0+(grep ref eq 'CODE', @INC), 2, '... but the expected dummy hook'; -} - -use lib 't/lib/blahdeblah'; - -push @INC, 't/lib/on-end'; - -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 4398c08d13..07c1975dc5 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/BaseIncExtender.pm b/dist/base/t/lib/BaseIncOptional.pm similarity index 71% rename from dist/base/t/lib/BaseIncExtender.pm rename to dist/base/t/lib/BaseIncOptional.pm index 47804503bf..78780e509d 100644 --- a/dist/base/t/lib/BaseIncExtender.pm +++ b/dist/base/t/lib/BaseIncOptional.pm @@ -1,10 +1,12 @@ -package BaseIncExtender; +package BaseIncOptional; BEGIN { package main; isnt $INC[-1], '.', 'no trailing dot in @INC during optional module load from base'; is 0+(grep ref eq 'CODE', @INC), 2, '... but the expected dummy hook'; } -use lib 't/lib/blahblah'; +use lib 't/lib/on-head'; + +push @INC, 't/lib/on-tail'; 1; -- Perl5 Master Repository
