From: Nicholas Clark Date: Thu, 13 Mar 2008 13:02:05 +0000 (+0000) Subject: Upgrade to Module::Pluggable 3.7 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=183ac38d1dc9c92293270377f1f75eb5bf966874;p=p5sagit%2Fp5-mst-13.2.git Upgrade to Module::Pluggable 3.7 p4raw-id: //depot/perl@33505 --- diff --git a/MANIFEST b/MANIFEST index e081987..75b69d4 100644 --- a/MANIFEST +++ b/MANIFEST @@ -3742,6 +3742,7 @@ t/Module_Pluggable/09require.t Module::Pluggable tests t/Module_Pluggable/10innerpack_inner.t Module::Pluggable tests t/Module_Pluggable/10innerpack_noinner.t Module::Pluggable tests t/Module_Pluggable/10innerpack_override.t Module::Pluggable tests +t/Module_Pluggable/10innerpack_super.t Module::Pluggable tests t/Module_Pluggable/10innerpack.t Module::Pluggable tests t/Module_Pluggable/11usetwice.t Module::Pluggable tests t/Module_Pluggable/12onlyarray.t Module::Pluggable tests @@ -3757,8 +3758,14 @@ t/Module_Pluggable/17devel_inner_package.t Module::Pluggable tests t/Module_Pluggable/18skipped_package.t Module::Pluggable tests t/Module_Pluggable/19can_ok_clobber.t Module::Pluggable tests t/Module_Pluggable/20dodgy_files.t Module::Pluggable tests +t/Module_Pluggable/21editor_junk.t Module::Pluggable tests t/Module_Pluggable/acme/Acme/MyTest/Plugin/Foo.pm Module::Pluggable tests t/Module_Pluggable/lib/Acme/MyTest/Plugin/Foo.pm Module::Pluggable tests +t/Module_Pluggable/lib/EditorJunk/Plugin/Foo.pm Module::Pluggable tests +t/Module_Pluggable/lib/EditorJunk/Plugin/Bar.pm~ Module::Pluggable tests +t/Module_Pluggable/lib/EditorJunk/Plugin/Bar.pm.swp Module::Pluggable tests +t/Module_Pluggable/lib/EditorJunk/Plugin/Bar.pm Module::Pluggable tests +t/Module_Pluggable/lib/EditorJunk/Plugin/Bar.pm.swo Module::Pluggable tests t/Module_Pluggable/lib/ExtTest/Plugin/Bar.plugin Module::Pluggable tests t/Module_Pluggable/lib/ExtTest/Plugin/Foo.plugin Module::Pluggable tests t/Module_Pluggable/lib/ExtTest/Plugin/Quux/Foo.plugin Module::Pluggable tests @@ -3772,7 +3779,6 @@ t/Module_Pluggable/lib/MyTest/Plugin/Bar.pm Module::Pluggable tests t/Module_Pluggable/lib/MyTest/Plugin/Foo.pm Module::Pluggable tests t/Module_Pluggable/lib/MyTest/Plugin/Quux/Foo.pm Module::Pluggable tests t/Module_Pluggable/lib/No/Middle.pm Module::Pluggable tests -t/Module_Pluggable/lib/OddTest/Plugin/-Dodgy.pm Module::Pluggable tests t/Module_Pluggable/lib/OddTest/Plugin/Foo.pm Module::Pluggable tests t/Module_Pluggable/lib/TA/C/A/I.pm Module::Pluggable tests t/mro/basic_01_c3.t mro tests diff --git a/ext/Module/Pluggable/Makefile.PL b/ext/Module/Pluggable/Makefile.PL index 8bf1034..ec527ec 100644 --- a/ext/Module/Pluggable/Makefile.PL +++ b/ext/Module/Pluggable/Makefile.PL @@ -1,16 +1,48 @@ +# Note: this file was auto-generated by Module::Build::Compat version 0.03 use ExtUtils::MakeMaker; +use FindBin; +use File::Spec::Functions qw(catfile); + +# VOS and VMS can't handle dodgy plugin names +# and VOS can't even unpack them so we create them on the +# fly and only run the tests if they're present +my %dodgy_files = ( + catfile(qw(OddTest Plugin -Dodgy.pm)) => 'OddTest::Plugin::-Dodgy', + catfile(qw(EditorJunk Plugin #Bar.pm#)) => 'EditorJunk::Bar', + catfile(qw(EditorJunk Plugin .#Bar.pm)) => 'EditorJunk::Bar', +); + +my $core = grep { $_ eq 'PERL_CORE=1' } @ARGV; +my @path = $core ? (File::Spec->updir, File::Spec->updir, File::Spec->updir, + "t", "Module_Pluggable") : ($FindBin::Bin,"t"); +my @files; + +if ($^O ne 'VMS' && $^O ne 'VOS') { + foreach my $test (keys %dodgy_files) { + my ($file) = (catfile(@path, "lib", $test)=~/^(.*)$/); + if (open(my $fh, ">", $file)) { + my $name = $dodgy_files{$test}; + print $fh "package $name;\nsub new {}\n1;"; + close($fh); + push @files, $file; + } + } +} WriteMakefile ( 'NAME' => 'Module::Pluggable', 'VERSION_FROM' => 'lib/Module/Pluggable.pm', - MAN3PODS => {}, # Pods will be built by installman. 'PREREQ_PM' => { 'File::Basename' => '0', 'File::Spec' => '3.00', 'Test::More' => '0.62' }, + 'INSTALLDIRS' => 'site', 'EXE_FILES' => [], - 'PL_FILES' => {} + 'PL_FILES' => {}, + 'realclean' => {FILES=> join ' ', @files}, + # In the core pods will be built by installman. + $core ? (MAN3PODS => {}) : (), ) ; diff --git a/ext/Module/Pluggable/lib/Devel/InnerPackage.pm b/ext/Module/Pluggable/lib/Devel/InnerPackage.pm index d5e7117..614a59a 100644 --- a/ext/Module/Pluggable/lib/Devel/InnerPackage.pm +++ b/ext/Module/Pluggable/lib/Devel/InnerPackage.pm @@ -17,7 +17,7 @@ Devel::InnerPackage - find all the inner packages of a package =head1 SYNOPSIS use Foo::Bar; - use Devel::innerPackage qw(list_packages); + use Devel::InnerPackage qw(list_packages); my @inner_packages = list_packages('Foo::Bar'); @@ -75,7 +75,7 @@ sub list_packages { !__PACKAGE__->_loaded($pack.$cand); # or @children; push @packs, @children; } - return grep {$_ !~ /::::ISA::CACHE/} @packs; + return grep {$_ !~ /::(::ISA::CACHE|SUPER)/} @packs; } ### XXX this is an inlining of the Class-Inspector->loaded() diff --git a/ext/Module/Pluggable/lib/Module/Pluggable.pm b/ext/Module/Pluggable/lib/Module/Pluggable.pm index 1020453..7100d5c 100644 --- a/ext/Module/Pluggable/lib/Module/Pluggable.pm +++ b/ext/Module/Pluggable/lib/Module/Pluggable.pm @@ -9,7 +9,7 @@ use Module::Pluggable::Object; # Peter Gibbons: I wouldn't say I've been missing it, Bob! -$VERSION = '3.6'; +$VERSION = '3.7'; sub import { my $class = shift; @@ -60,8 +60,9 @@ sub import { no strict 'refs'; - no warnings 'redefine'; - *{"$package\::$sub"} = $subroutine; + no warnings qw(redefine prototype); + + *{"$package\::$sub"} = $subroutine; *{"$package\::search_path"} = $searchsub; *{"$package\::only"} = $onlysub; *{"$package\::except"} = $exceptsub; @@ -297,6 +298,14 @@ By supplying a new C then you can change this behaviour e.g file_regex => qr/\.plugin$/ +=head2 include_editor_junk + +By default C ignores files that look like they were +left behind by editors. Currently this means files ending in F<~> (~), +the extensions F<.swp> or F<.swo>, or files beginning with F<.#>. + +Setting C changes C so it does +not ignore any files it finds. =head1 METHODs diff --git a/ext/Module/Pluggable/lib/Module/Pluggable/Object.pm b/ext/Module/Pluggable/lib/Module/Pluggable/Object.pm index 61951bd..d99eb9d 100644 --- a/ext/Module/Pluggable/lib/Module/Pluggable/Object.pm +++ b/ext/Module/Pluggable/lib/Module/Pluggable/Object.pm @@ -20,6 +20,10 @@ sub new { } +### Eugggh, this code smells +### This is what happens when you keep adding patches +### *sigh* + sub plugins { my $self = shift; @@ -46,7 +50,7 @@ sub plugins { # check to see if we're running under test - my @SEARCHDIR = exists $INC{"blib.pm"} && $filename =~ m!(^|/)blib/! ? grep {/blib/} @INC : @INC; + my @SEARCHDIR = exists $INC{"blib.pm"} && defined $filename && $filename =~ m!(^|/)blib/! ? grep {/blib/} @INC : @INC; # add any search_dir params unshift @SEARCHDIR, @{$self->{'search_dirs'}} if defined $self->{'search_dirs'}; @@ -151,6 +155,8 @@ sub search_paths { # parse the file to get the name my ($name, $directory, $suffix) = fileparse($file, $file_regex); + next if (!$self->{include_editor_junk} && $self->_is_editor_junk($name)); + $directory = abs2rel($directory, $sp); # If we have a mixed-case package name, assume case has been preserved @@ -209,6 +215,22 @@ sub search_paths { return @plugins; } +sub _is_editor_junk { + my $self = shift; + my $name = shift; + + # Emacs (and other Unix-y editors) leave temp files ending in a + # tilde as a backup. + return 1 if $name =~ /~$/; + # Emacs makes these files while a buffer is edited but not yet + # saved. + return 1 if $name =~ /^\.#/; + # Vim can leave these files behind if it crashes. + return 1 if $name =~ /\.sw[po]$/; + + return 0; +} + sub handle_finding_plugin { my $self = shift; my $plugin = shift; @@ -299,6 +321,14 @@ looks through a search path for .pm files and turn those into class names. Optionally it instantiates those classes for you. +This object is wrapped by C. If you want to do something +odd or add non-general special features you're probably best to wrap this +and produce your own subclass. + +=head1 OPTIONS + +See the C docs. + =head1 AUTHOR Simon Wistow diff --git a/t/Module_Pluggable/02alsoworks.t b/t/Module_Pluggable/02alsoworks.t index c7b00ad..131df29 100644 --- a/t/Module_Pluggable/02alsoworks.t +++ b/t/Module_Pluggable/02alsoworks.t @@ -2,7 +2,7 @@ use strict; use FindBin; -use lib "$FindBin::Bin/lib"; +use lib (($FindBin::Bin."/lib")=~/^(.*)$/); use Test::More tests => 5; my $foo; diff --git a/t/Module_Pluggable/02works.t b/t/Module_Pluggable/02works.t index 6c39452..f748344 100644 --- a/t/Module_Pluggable/02works.t +++ b/t/Module_Pluggable/02works.t @@ -2,7 +2,7 @@ use strict; use FindBin; -use lib "$FindBin::Bin/lib"; +use lib (($FindBin::Bin."/lib")=~/^(.*)$/); use Test::More tests => 5; my $foo; diff --git a/t/Module_Pluggable/03diffname.t b/t/Module_Pluggable/03diffname.t index b4a881b..d449fd0 100644 --- a/t/Module_Pluggable/03diffname.t +++ b/t/Module_Pluggable/03diffname.t @@ -2,7 +2,7 @@ use strict; use FindBin; -use lib "$FindBin::Bin/lib"; +use lib (($FindBin::Bin."/lib")=~/^(.*)$/); use Test::More tests => 3; my $foo; diff --git a/t/Module_Pluggable/04acmedir.t b/t/Module_Pluggable/04acmedir.t index 7154486..e2572fe 100644 --- a/t/Module_Pluggable/04acmedir.t +++ b/t/Module_Pluggable/04acmedir.t @@ -2,7 +2,7 @@ use strict; use FindBin; -use lib "$FindBin::Bin/lib"; +use lib (($FindBin::Bin."/lib")=~/^(.*)$/); use Test::More tests => 3; diff --git a/t/Module_Pluggable/04acmedir_single.t b/t/Module_Pluggable/04acmedir_single.t index e2abce9..adc5304 100644 --- a/t/Module_Pluggable/04acmedir_single.t +++ b/t/Module_Pluggable/04acmedir_single.t @@ -2,7 +2,7 @@ use strict; use FindBin; -use lib "$FindBin::Bin/lib"; +use lib (($FindBin::Bin."/lib")=~/^(.*)$/); use Test::More tests => 3; diff --git a/t/Module_Pluggable/04acmepath.t b/t/Module_Pluggable/04acmepath.t index bb1b88b..540158c 100644 --- a/t/Module_Pluggable/04acmepath.t +++ b/t/Module_Pluggable/04acmepath.t @@ -2,7 +2,7 @@ use strict; use FindBin; -use lib "$FindBin::Bin/lib"; +use lib (($FindBin::Bin."/lib")=~/^(.*)$/); use Test::More tests => 3; diff --git a/t/Module_Pluggable/04acmepath_single.t b/t/Module_Pluggable/04acmepath_single.t index bf02854..976e77e 100644 --- a/t/Module_Pluggable/04acmepath_single.t +++ b/t/Module_Pluggable/04acmepath_single.t @@ -2,7 +2,7 @@ use strict; use FindBin; -use lib "$FindBin::Bin/lib"; +use lib (($FindBin::Bin."/lib")=~/^(.*)$/); use Test::More tests => 3; diff --git a/t/Module_Pluggable/05postpath.t b/t/Module_Pluggable/05postpath.t index be16010..08c4052 100644 --- a/t/Module_Pluggable/05postpath.t +++ b/t/Module_Pluggable/05postpath.t @@ -2,7 +2,7 @@ use strict; use FindBin; -use lib "$FindBin::Bin/lib"; +use lib (($FindBin::Bin."/lib")=~/^(.*)$/); use Test::More tests => 3; diff --git a/t/Module_Pluggable/06multipath.t b/t/Module_Pluggable/06multipath.t index 4c9a16b..6f74591 100644 --- a/t/Module_Pluggable/06multipath.t +++ b/t/Module_Pluggable/06multipath.t @@ -2,7 +2,7 @@ use strict; use FindBin; -use lib "$FindBin::Bin/lib"; +use lib (($FindBin::Bin."/lib")=~/^(.*)$/); use Test::More tests => 3; diff --git a/t/Module_Pluggable/07instantiate.t b/t/Module_Pluggable/07instantiate.t index befc15a..352d4d0 100644 --- a/t/Module_Pluggable/07instantiate.t +++ b/t/Module_Pluggable/07instantiate.t @@ -2,7 +2,7 @@ use strict; use FindBin; -use lib "$FindBin::Bin/lib"; +use lib (($FindBin::Bin."/lib")=~/^(.*)$/); use Test::More tests => 6; my $foo; @@ -26,7 +26,7 @@ package MyTest; use File::Spec::Functions qw(catdir); use strict; use FindBin; -use lib "$FindBin::Bin/lib"; +use lib (($FindBin::Bin."/lib")=~/^(.*)$/); use Module::Pluggable (search_path => ["MyTest::Extend::Plugin"], sub_name => 'booga', instantiate => 'new'); use Module::Pluggable (search_path => ["MyTest::Extend::Plugin"], sub_name => 'wooga', instantiate => 'nosomuchmethod'); diff --git a/t/Module_Pluggable/08nothing.t b/t/Module_Pluggable/08nothing.t index 78d1007..f5c6487 100644 --- a/t/Module_Pluggable/08nothing.t +++ b/t/Module_Pluggable/08nothing.t @@ -2,7 +2,7 @@ use strict; use FindBin; -use lib "$FindBin::Bin/lib"; +use lib (($FindBin::Bin."/lib")=~/^(.*)$/); use Test::More tests => 2; diff --git a/t/Module_Pluggable/09require.t b/t/Module_Pluggable/09require.t index 106e2c4..af5de5f 100644 --- a/t/Module_Pluggable/09require.t +++ b/t/Module_Pluggable/09require.t @@ -2,7 +2,7 @@ use strict; use FindBin; -use lib "$FindBin::Bin/lib"; +use lib (($FindBin::Bin."/lib")=~/^(.*)$/); use Test::More tests => 2; my $t = MyTest->new(); diff --git a/t/Module_Pluggable/10innerpack.t b/t/Module_Pluggable/10innerpack.t index fc7a213..0653fc8 100644 --- a/t/Module_Pluggable/10innerpack.t +++ b/t/Module_Pluggable/10innerpack.t @@ -2,7 +2,7 @@ use strict; use FindBin; -use lib "$FindBin::Bin/lib"; +use lib (($FindBin::Bin."/lib")=~/^(.*)$/); use Test::More tests => 4; diff --git a/t/Module_Pluggable/10innerpack_inner.t b/t/Module_Pluggable/10innerpack_inner.t index 55edcd9..054d9b6 100644 --- a/t/Module_Pluggable/10innerpack_inner.t +++ b/t/Module_Pluggable/10innerpack_inner.t @@ -2,7 +2,7 @@ use strict; use FindBin; -use lib "$FindBin::Bin/lib"; +use lib (($FindBin::Bin."/lib")=~/^(.*)$/); use Test::More tests => 3; diff --git a/t/Module_Pluggable/10innerpack_noinner.t b/t/Module_Pluggable/10innerpack_noinner.t index 5d40cd5..1d670b0 100644 --- a/t/Module_Pluggable/10innerpack_noinner.t +++ b/t/Module_Pluggable/10innerpack_noinner.t @@ -2,7 +2,7 @@ use strict; use FindBin; -use lib "$FindBin::Bin/lib"; +use lib (($FindBin::Bin."/lib")=~/^(.*)$/); use Test::More tests => 3; diff --git a/t/Module_Pluggable/10innerpack_override.t b/t/Module_Pluggable/10innerpack_override.t index 039b845..f9e863e 100644 --- a/t/Module_Pluggable/10innerpack_override.t +++ b/t/Module_Pluggable/10innerpack_override.t @@ -2,7 +2,7 @@ use strict; use FindBin; -use lib "$FindBin::Bin/lib"; +use lib (($FindBin::Bin."/lib")=~/^(.*)$/); use Test::More tests => 3; diff --git a/t/Module_Pluggable/10innerpack_super.t b/t/Module_Pluggable/10innerpack_super.t new file mode 100644 index 0000000..e9a58bd --- /dev/null +++ b/t/Module_Pluggable/10innerpack_super.t @@ -0,0 +1,29 @@ +#!perl -wT + +use Test::More tests => 3; +use strict; +use_ok('Devel::InnerPackage'); +Bar->whee; +is_deeply([Devel::InnerPackage::list_packages("Bar")],[], "Don't pick up ::SUPER pseudo stash"); +is_deeply([Devel::InnerPackage::list_packages("Foo")],['Foo::Bar'], "Still pick up other inner package"); + +package Foo; + +sub whee { + 1; +} + +package Foo::Bar; + +sub whee {} + +package Bar; +use base 'Foo'; + +sub whee { + shift->SUPER::whee; + 2; +} + + +1; diff --git a/t/Module_Pluggable/11usetwice.t b/t/Module_Pluggable/11usetwice.t index 0f6a1ba..8240318 100644 --- a/t/Module_Pluggable/11usetwice.t +++ b/t/Module_Pluggable/11usetwice.t @@ -2,7 +2,7 @@ use strict; use FindBin; -use lib "$FindBin::Bin/lib"; +use lib (($FindBin::Bin."/lib")=~/^(.*)$/); use Test::More tests => 3; my $foo; diff --git a/t/Module_Pluggable/12only.t b/t/Module_Pluggable/12only.t index 6164c42..1150b60 100644 --- a/t/Module_Pluggable/12only.t +++ b/t/Module_Pluggable/12only.t @@ -2,7 +2,7 @@ use strict; use FindBin; -use lib "$FindBin::Bin/lib"; +use lib (($FindBin::Bin."/lib")=~/^(.*)$/); use Test::More tests => 10; { diff --git a/t/Module_Pluggable/12onlyarray.t b/t/Module_Pluggable/12onlyarray.t index 5ecc654..a37e777 100644 --- a/t/Module_Pluggable/12onlyarray.t +++ b/t/Module_Pluggable/12onlyarray.t @@ -2,7 +2,7 @@ use strict; use FindBin; -use lib "$FindBin::Bin/lib"; +use lib (($FindBin::Bin."/lib")=~/^(.*)$/); use Test::More tests => 10; { diff --git a/t/Module_Pluggable/12onlyregex.t b/t/Module_Pluggable/12onlyregex.t index eff6a16..78a9bd5 100644 --- a/t/Module_Pluggable/12onlyregex.t +++ b/t/Module_Pluggable/12onlyregex.t @@ -2,7 +2,7 @@ use strict; use FindBin; -use lib "$FindBin::Bin/lib"; +use lib (($FindBin::Bin."/lib")=~/^(.*)$/); use Test::More tests => 10; { diff --git a/t/Module_Pluggable/13except.t b/t/Module_Pluggable/13except.t index 0dbfb20..e08ffa9 100644 --- a/t/Module_Pluggable/13except.t +++ b/t/Module_Pluggable/13except.t @@ -2,7 +2,7 @@ use strict; use FindBin; -use lib "$FindBin::Bin/lib"; +use lib (($FindBin::Bin."/lib")=~/^(.*)$/); use Test::More tests => 10; { diff --git a/t/Module_Pluggable/13exceptarray.t b/t/Module_Pluggable/13exceptarray.t index a6313bd..ec61ff4 100644 --- a/t/Module_Pluggable/13exceptarray.t +++ b/t/Module_Pluggable/13exceptarray.t @@ -1,8 +1,8 @@ -#!perl -w +#!perl -wT use strict; use FindBin; -use lib "$FindBin::Bin/lib"; +use lib (($FindBin::Bin."/lib")=~/^(.*)$/); use Test::More tests => 10; { diff --git a/t/Module_Pluggable/13exceptregex.t b/t/Module_Pluggable/13exceptregex.t index e3f2638..2d842b3 100644 --- a/t/Module_Pluggable/13exceptregex.t +++ b/t/Module_Pluggable/13exceptregex.t @@ -1,8 +1,8 @@ -#!perl -w +#!perl -wT use strict; use FindBin; -use lib "$FindBin::Bin/lib"; +use lib (($FindBin::Bin."/lib")=~/^(.*)$/); use Test::More tests => 10; { diff --git a/t/Module_Pluggable/14package.t b/t/Module_Pluggable/14package.t index 3ba56ed..aaca94c 100644 --- a/t/Module_Pluggable/14package.t +++ b/t/Module_Pluggable/14package.t @@ -2,7 +2,7 @@ use strict; use FindBin; -use lib "$FindBin::Bin/lib"; +use lib (($FindBin::Bin."/lib")=~/^(.*)$/); use Test::More tests => 5; my $foo; diff --git a/t/Module_Pluggable/15topicsafe.t b/t/Module_Pluggable/15topicsafe.t index abc980f..49305f2 100644 --- a/t/Module_Pluggable/15topicsafe.t +++ b/t/Module_Pluggable/15topicsafe.t @@ -2,7 +2,7 @@ use strict; use FindBin; -use lib "$FindBin::Bin/lib"; +use lib (($FindBin::Bin."/lib")=~/^(.*)$/); use Test::More 'no_plan'; use Module::Pluggable search_path => 'Acme::MyTest'; diff --git a/t/Module_Pluggable/16different_extension.t b/t/Module_Pluggable/16different_extension.t index 3f1a4da..f628a7c 100644 --- a/t/Module_Pluggable/16different_extension.t +++ b/t/Module_Pluggable/16different_extension.t @@ -2,7 +2,7 @@ use strict; use FindBin; -use lib "$FindBin::Bin/lib"; +use lib (($FindBin::Bin."/lib")=~/^(.*)$/); use Test::More tests => 5; my $foo; diff --git a/t/Module_Pluggable/17devel_inner_package.t b/t/Module_Pluggable/17devel_inner_package.t index 5fabdbf..30f3256 100644 --- a/t/Module_Pluggable/17devel_inner_package.t +++ b/t/Module_Pluggable/17devel_inner_package.t @@ -3,7 +3,7 @@ use Test::More tests => 3; use Devel::InnerPackage qw(list_packages); use FindBin; -use lib "$FindBin::Bin/lib"; +use lib (($FindBin::Bin."/lib")=~/^(.*)$/); my @packages; diff --git a/t/Module_Pluggable/18skipped_package.t b/t/Module_Pluggable/18skipped_package.t index 3991772..c580d68 100644 --- a/t/Module_Pluggable/18skipped_package.t +++ b/t/Module_Pluggable/18skipped_package.t @@ -2,7 +2,7 @@ use Test::More tests => 1; use FindBin; -use lib "$FindBin::Bin/lib"; +use lib (($FindBin::Bin."/lib")=~/^(.*)$/); use Devel::InnerPackage qw(list_packages); use No::Middle; diff --git a/t/Module_Pluggable/19can_ok_clobber.t b/t/Module_Pluggable/19can_ok_clobber.t index 78b03cb..07c598b 100644 --- a/t/Module_Pluggable/19can_ok_clobber.t +++ b/t/Module_Pluggable/19can_ok_clobber.t @@ -3,7 +3,7 @@ use strict; use warnings; use Data::Dumper; use FindBin; -use lib "$FindBin::Bin/lib"; +use lib (($FindBin::Bin."/lib")=~/^(.*)$/); use Test::More tests=>5; diff --git a/t/Module_Pluggable/20dodgy_files.t b/t/Module_Pluggable/20dodgy_files.t index 2486402..8c0eb8e 100644 --- a/t/Module_Pluggable/20dodgy_files.t +++ b/t/Module_Pluggable/20dodgy_files.t @@ -1,7 +1,7 @@ #!perl -w BEGIN { - if ($^O eq 'VMS') { + if ($^O eq 'VMS' || $^O eq 'VOS') { print "1..0 # Skip: can't handle misspelled plugin names\n"; exit; } @@ -9,8 +9,18 @@ BEGIN { use strict; use FindBin; -use lib "$FindBin::Bin/lib"; -use Test::More tests => 5; +use Test::More; +use lib (($FindBin::Bin."/lib")=~/^(.*)$/); +use File::Spec::Functions qw(catfile); + + +my ($dodgy_file) = (catfile($FindBin::Bin, "lib", "OddTest", "Plugin", "-Dodgy.pm")=~/^(.*)$/); +unless (-f $dodgy_file) { + plan skip_all => "Can't handle misspelled plugin names\n"; +} else { + plan tests => 5; +} + my $foo; ok($foo = OddTest->new()); diff --git a/t/Module_Pluggable/21editor_junk.t b/t/Module_Pluggable/21editor_junk.t new file mode 100644 index 0000000..5f4b52b --- /dev/null +++ b/t/Module_Pluggable/21editor_junk.t @@ -0,0 +1,53 @@ +#!perl -w + +use Test::More; +use FindBin; +use lib (($FindBin::Bin."/lib")=~/^(.*)$/); +use Module::Pluggable::Object; +use File::Spec::Functions qw(catfile); + +my ($dodgy_file) = (catfile($FindBin::Bin,"lib", "EditorJunk", "Plugin", "#Bar.pm#")=~/^(.*)$/); +unless (-f $dodgy_file) { + plan skip_all => "Can't handle plugin names with octothorpes\n"; +} else { + plan tests => 4; +} + + + +my $foo; +ok($foo = EditorJunk->new()); + +my @plugins; +my @expected = qw(EditorJunk::Plugin::Bar EditorJunk::Plugin::Foo); +ok(@plugins = sort $foo->plugins); + +is_deeply(\@plugins, \@expected, "is deeply"); + + +my $mpo = Module::Pluggable::Object->new( + package => 'EditorJunk', + filename => __FILE__, + include_editor_junk => 1, +); + +@expected = ('EditorJunk::Plugin::.#Bar', 'EditorJunk::Plugin::Bar', 'EditorJunk::Plugin::Foo'); +@plugins = sort $mpo->plugins(); +is_deeply(\@plugins, \@expected, "is deeply"); + + + +package EditorJunk; + +use strict; +use Module::Pluggable; + + +sub new { + my $class = shift; + return bless {}, $class; + +} +1; + + diff --git a/t/Module_Pluggable/lib/EditorJunk/Plugin/Bar.pm b/t/Module_Pluggable/lib/EditorJunk/Plugin/Bar.pm new file mode 100644 index 0000000..dcc870c --- /dev/null +++ b/t/Module_Pluggable/lib/EditorJunk/Plugin/Bar.pm @@ -0,0 +1,9 @@ +package EditorJunk::Bar; + + +use strict; + + +1; + + diff --git a/t/Module_Pluggable/lib/EditorJunk/Plugin/Bar.pm.swo b/t/Module_Pluggable/lib/EditorJunk/Plugin/Bar.pm.swo new file mode 100644 index 0000000..dcc870c --- /dev/null +++ b/t/Module_Pluggable/lib/EditorJunk/Plugin/Bar.pm.swo @@ -0,0 +1,9 @@ +package EditorJunk::Bar; + + +use strict; + + +1; + + diff --git a/t/Module_Pluggable/lib/EditorJunk/Plugin/Bar.pm.swp b/t/Module_Pluggable/lib/EditorJunk/Plugin/Bar.pm.swp new file mode 100644 index 0000000..dcc870c --- /dev/null +++ b/t/Module_Pluggable/lib/EditorJunk/Plugin/Bar.pm.swp @@ -0,0 +1,9 @@ +package EditorJunk::Bar; + + +use strict; + + +1; + + diff --git a/t/Module_Pluggable/lib/EditorJunk/Plugin/Bar.pm~ b/t/Module_Pluggable/lib/EditorJunk/Plugin/Bar.pm~ new file mode 100644 index 0000000..dcc870c --- /dev/null +++ b/t/Module_Pluggable/lib/EditorJunk/Plugin/Bar.pm~ @@ -0,0 +1,9 @@ +package EditorJunk::Bar; + + +use strict; + + +1; + + diff --git a/t/Module_Pluggable/lib/EditorJunk/Plugin/Foo.pm b/t/Module_Pluggable/lib/EditorJunk/Plugin/Foo.pm new file mode 100644 index 0000000..64b8bf4 --- /dev/null +++ b/t/Module_Pluggable/lib/EditorJunk/Plugin/Foo.pm @@ -0,0 +1,9 @@ +package EditorJunk::Foo; + + +use strict; + + +1; + + diff --git a/t/Module_Pluggable/lib/OddTest/Plugin/-Dodgy.pm b/t/Module_Pluggable/lib/OddTest/Plugin/-Dodgy.pm deleted file mode 100644 index 326e867..0000000 --- a/t/Module_Pluggable/lib/OddTest/Plugin/-Dodgy.pm +++ /dev/null @@ -1,5 +0,0 @@ -package OddFiles::Plugin::Dodgy; - -sub new {} - -1;