summaryrefslogtreecommitdiff
path: root/dist/ExtUtils-Install
diff options
context:
space:
mode:
authorDavid Golden <dagolden@cpan.org>2011-07-20 19:49:43 -0400
committerDavid Golden <dagolden@cpan.org>2011-07-20 21:17:41 -0400
commit57126352f86d7519d61962a30eb9c2204826e035 (patch)
treeb9949c7f8be4e7acd3334ab40665a840b9a2717f /dist/ExtUtils-Install
parent71449ad0af04ebee5fa2c3d8d9346254d35f05d8 (diff)
downloadperl-57126352f86d7519d61962a30eb9c2204826e035.tar.gz
Adds 'skip_cwd' parameter to ExtUtils::Installed.
With this new parameter, the current directory is not included in the installed module search. This avoids finding modules from other perls which happen to be below the current directory.
Diffstat (limited to 'dist/ExtUtils-Install')
-rw-r--r--dist/ExtUtils-Install/Changes15
-rw-r--r--dist/ExtUtils-Install/lib/ExtUtils/Install.pm4
-rw-r--r--dist/ExtUtils-Install/lib/ExtUtils/Installed.pm15
-rw-r--r--dist/ExtUtils-Install/t/Installed.t49
4 files changed, 74 insertions, 9 deletions
diff --git a/dist/ExtUtils-Install/Changes b/dist/ExtUtils-Install/Changes
index ccb1df5088..2fc02bbf83 100644
--- a/dist/ExtUtils-Install/Changes
+++ b/dist/ExtUtils-Install/Changes
@@ -1,5 +1,20 @@
Revision history for ExtUtils-Install
+1.57
+
+Adds 'skip_cwd' parameter to ExtUtils::Installed. With this new parameter,
+the current directory is not included in the installed module search. This
+avoids finding modules from other perls which happen to be below the
+current directory.
+
+1.56
+
+Pod fixes.
+
+1.55
+
+Pod fixes.
+
1.54
This is a "no-change" version bump because I pushed the v1.53 change
diff --git a/dist/ExtUtils-Install/lib/ExtUtils/Install.pm b/dist/ExtUtils-Install/lib/ExtUtils/Install.pm
index 3b030a511a..0b40af2980 100644
--- a/dist/ExtUtils-Install/lib/ExtUtils/Install.pm
+++ b/dist/ExtUtils-Install/lib/ExtUtils/Install.pm
@@ -38,11 +38,11 @@ ExtUtils::Install - install files from here to there
=head1 VERSION
-1.55
+1.57
=cut
-$VERSION = '1.56'; # <---- dont forget to update the POD section just above this line!
+$VERSION = '1.57'; # <---- dont forget to update the POD section just above this line!
$VERSION = eval $VERSION;
=pod
diff --git a/dist/ExtUtils-Install/lib/ExtUtils/Installed.pm b/dist/ExtUtils-Install/lib/ExtUtils/Installed.pm
index 9cb1fc10d7..afc52a5188 100644
--- a/dist/ExtUtils-Install/lib/ExtUtils/Installed.pm
+++ b/dist/ExtUtils-Install/lib/ExtUtils/Installed.pm
@@ -17,7 +17,7 @@ my $DOSISH = ($^O =~ /^(MSWin\d\d|os2|dos|mint)$/);
require VMS::Filespec if $Is_VMS;
use vars qw($VERSION);
-$VERSION = '1.999_001';
+$VERSION = '1.999002';
$VERSION = eval $VERSION;
sub _is_prefix {
@@ -162,7 +162,9 @@ sub new {
}
{
my %dupe;
- @{$self->{':private:'}{LIBDIRS}} = grep { -e $_ && !$dupe{$_}++ }
+ @{$self->{':private:'}{LIBDIRS}} =
+ grep { $_ ne '.' || ! $args{skip_cwd} }
+ grep { -e $_ && !$dupe{$_}++ }
@{$self->{':private:'}{EXTRA}}, @{$self->{':private:'}{INC}};
}
@@ -327,7 +329,7 @@ ExtUtils::Installed - Inventory management of installed modules
=head1 SYNOPSIS
use ExtUtils::Installed;
- my ($inst) = ExtUtils::Installed->new();
+ my ($inst) = ExtUtils::Installed->new( skip_cwd => 1 );
my (@modules) = $inst->modules();
my (@missing) = $inst->validate("DBI");
my $all_files = $inst->files("DBI");
@@ -369,6 +371,11 @@ information from C<%Config::Config> and the default module search
paths C<@INC>. The packlists are read using the
L<ExtUtils::Packlist> module.
+If the named parameter C<skip_cwd> is true, the current directory C<.> will
+be stripped from C<@INC> before searching for .packlists. This keeps
+ExtUtils::Installed from finding modules installed in other perls that
+happen to be located below the current directory.
+
If the named parameter C<config_override> is specified,
it should be a reference to a hash which contains all information
usually found in C<%Config::Config>. For example, you can obtain
@@ -389,7 +396,7 @@ from C<@INC>.
B<Note>: You probably do not want to use these options alone, almost always
you will want to set both together.
-The parameter c<extra_libs> can be used to specify B<additional> paths to
+The parameter C<extra_libs> can be used to specify B<additional> paths to
search for installed modules. For instance
my $installed = ExtUtils::Installed->new(extra_libs=>["/my/lib/path"]);
diff --git a/dist/ExtUtils-Install/t/Installed.t b/dist/ExtUtils-Install/t/Installed.t
index 6e0be3d720..5c5c4d3d09 100644
--- a/dist/ExtUtils-Install/t/Installed.t
+++ b/dist/ExtUtils-Install/t/Installed.t
@@ -14,7 +14,7 @@ use File::Path;
use File::Basename;
use File::Spec;
-use Test::More tests => 63;
+use Test::More tests => 73;
BEGIN { use_ok( 'ExtUtils::Installed' ) }
@@ -107,8 +107,7 @@ my $fake_mod_dir = File::Spec->catdir(cwd(), 'auto', 'FakeMod');
sitearchexp => $fake_mod_dir,
);
- # necessary to fool new()
- push @INC, $fake_mod_dir;
+ # should find $fake_mod_dir via '.' in @INC
my $realei = ExtUtils::Installed->new();
isa_ok( $realei, 'ExtUtils::Installed' );
@@ -122,6 +121,50 @@ my $fake_mod_dir = File::Spec->catdir(cwd(), 'auto', 'FakeMod');
'... should find version in modules' );
}
+{
+ # avoid warning and death by localizing glob
+ local *ExtUtils::Installed::Config;
+ %ExtUtils::Installed::Config = (
+ %Config,
+ archlibexp => cwd(),
+ sitearchexp => $fake_mod_dir,
+ );
+
+ # disable '.' search
+
+ my $realei = ExtUtils::Installed->new( skip_cwd => 1 );
+ isa_ok( $realei, 'ExtUtils::Installed' );
+ isa_ok( $realei->{Perl}{packlist}, 'ExtUtils::Packlist' );
+ is( $realei->{Perl}{version}, $Config{version},
+ 'new() should set Perl version from %Config' );
+
+ ok( ! exists $realei->{FakeMod}, 'new( skip_cwd => 1 ) should fail to find modules with .packlists');
+}
+
+{
+ # avoid warning and death by localizing glob
+ local *ExtUtils::Installed::Config;
+ %ExtUtils::Installed::Config = (
+ %Config,
+ archlibexp => cwd(),
+ sitearchexp => $fake_mod_dir,
+ );
+
+ # necessary to fool new() since we'll disable searching '.'
+ push @INC, $fake_mod_dir;
+
+ my $realei = ExtUtils::Installed->new( skip_cwd => 1 );
+ isa_ok( $realei, 'ExtUtils::Installed' );
+ isa_ok( $realei->{Perl}{packlist}, 'ExtUtils::Packlist' );
+ is( $realei->{Perl}{version}, $Config{version},
+ 'new() should set Perl version from %Config' );
+
+ ok( exists $realei->{FakeMod}, 'new() should find modules with .packlists');
+ isa_ok( $realei->{FakeMod}{packlist}, 'ExtUtils::Packlist' );
+ is( $realei->{FakeMod}{version}, '1.1.1',
+ '... should find version in modules' );
+}
+
# Now try this using PERL5LIB
{
local $ENV{PERL5LIB} = join $Config{path_sep}, $fake_mod_dir;