diff options
author | Nicholas Clark <nick@ccl4.org> | 2009-09-10 11:08:39 +0100 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2009-09-10 11:33:22 +0100 |
commit | fb78ba4be2872a911ecd409537deabc67447f706 (patch) | |
tree | c434778421c491bbbd130340ab745f57e6da2d6a /lib/ExtUtils/t | |
parent | 2db10ba327c7c0a1b993bf71c5feb22a2044498a (diff) | |
download | perl-fb78ba4be2872a911ecd409537deabc67447f706.tar.gz |
Move ExtUtils::Install from lib to ext.
Diffstat (limited to 'lib/ExtUtils/t')
-rw-r--r-- | lib/ExtUtils/t/Install.t | 194 | ||||
-rw-r--r-- | lib/ExtUtils/t/InstallWithMM.t | 95 | ||||
-rw-r--r-- | lib/ExtUtils/t/Installapi2.t | 238 | ||||
-rw-r--r-- | lib/ExtUtils/t/Installed.t | 313 | ||||
-rw-r--r-- | lib/ExtUtils/t/Packlist.t | 174 | ||||
-rw-r--r-- | lib/ExtUtils/t/can_write_dir.t | 61 |
6 files changed, 0 insertions, 1075 deletions
diff --git a/lib/ExtUtils/t/Install.t b/lib/ExtUtils/t/Install.t deleted file mode 100644 index a30515ea94..0000000000 --- a/lib/ExtUtils/t/Install.t +++ /dev/null @@ -1,194 +0,0 @@ -#!/usr/bin/perl -w - -# Test ExtUtils::Install. - -BEGIN { - if( $ENV{PERL_CORE} ) { - @INC = ('../../lib', '../lib', 'lib'); - } - else { - unshift @INC, 't/lib'; - } -} -chdir 't'; - -use strict; -use TieOut; -use File::Path; -use File::Spec; - -use Test::More tests => 52; - -use MakeMaker::Test::Setup::BFD; - -BEGIN { use_ok('ExtUtils::Install') } -# ensure the env doesnt pollute our tests -local $ENV{EU_INSTALL_ALWAYS_COPY}; -local $ENV{EU_ALWAYS_COPY}; - -# Check exports. -foreach my $func (qw(install uninstall pm_to_blib install_default)) { - can_ok(__PACKAGE__, $func); -} - - -ok( setup_recurs(), 'setup' ); -END { - ok( chdir File::Spec->updir ); - ok( teardown_recurs(), 'teardown' ); -} - -chdir 'Big-Dummy'; - -my $stdout = tie *STDOUT, 'TieOut'; -pm_to_blib( { 'lib/Big/Dummy.pm' => 'blib/lib/Big/Dummy.pm' }, - 'blib/lib/auto' - ); -END { rmtree 'blib' } - -ok( -d 'blib/lib', 'pm_to_blib created blib dir' ); -ok( -r 'blib/lib/Big/Dummy.pm', ' copied .pm file' ); -ok( -r 'blib/lib/auto', ' created autosplit dir' ); -is( $stdout->read, "cp lib/Big/Dummy.pm blib/lib/Big/Dummy.pm\n" ); - -pm_to_blib( { 'lib/Big/Dummy.pm' => 'blib/lib/Big/Dummy.pm' }, - 'blib/lib/auto' - ); -ok( -d 'blib/lib', 'second run, blib dir still there' ); -ok( -r 'blib/lib/Big/Dummy.pm', ' .pm file still there' ); -ok( -r 'blib/lib/auto', ' autosplit still there' ); -is( $stdout->read, "Skip blib/lib/Big/Dummy.pm (unchanged)\n" ); - -install( { 'blib/lib' => 'install-test/lib/perl', - read => 'install-test/packlist', - write => 'install-test/packlist' - }, - 0, 1); -ok( ! -d 'install-test/lib/perl', 'install made dir (dry run)'); -ok( ! -r 'install-test/lib/perl/Big/Dummy.pm', - ' .pm file installed (dry run)'); -ok( ! -r 'install-test/packlist', ' packlist exists (dry run)'); - -install( { 'blib/lib' => 'install-test/lib/perl', - read => 'install-test/packlist', - write => 'install-test/packlist' - } ); -ok( -d 'install-test/lib/perl', 'install made dir' ); -ok( -r 'install-test/lib/perl/Big/Dummy.pm', ' .pm file installed' ); -ok(!-r 'install-test/lib/perl/Big/Dummy.SKIP', ' ignored .SKIP file' ); -ok( -r 'install-test/packlist', ' packlist exists' ); - -open(PACKLIST, 'install-test/packlist' ); -my %packlist = map { chomp; ($_ => 1) } <PACKLIST>; -close PACKLIST; - -# On case-insensitive filesystems (ie. VMS), the keys of the packlist might -# be lowercase. :( -my $native_dummy = File::Spec->catfile(qw(install-test lib perl Big Dummy.pm)); -is( keys %packlist, 1 ); -is( lc((keys %packlist)[0]), lc $native_dummy, 'packlist written' ); - - -# Test UNINST=1 preserving same versions in other dirs. -install( { 'blib/lib' => 'install-test/other_lib/perl', - read => 'install-test/packlist', - write => 'install-test/packlist' - }, - 0, 0, 1); -ok( -d 'install-test/other_lib/perl', 'install made other dir' ); -ok( -r 'install-test/other_lib/perl/Big/Dummy.pm', ' .pm file installed' ); -ok( -r 'install-test/packlist', ' packlist exists' ); -ok( -r 'install-test/lib/perl/Big/Dummy.pm', ' UNINST=1 preserved same' ); - - -chmod 0644, 'blib/lib/Big/Dummy.pm' or die $!; -open(DUMMY, ">>blib/lib/Big/Dummy.pm") or die $!; -print DUMMY "Extra stuff\n"; -close DUMMY; - - -# Test UNINST=0 does not remove other versions in other dirs. -{ - ok( -r 'install-test/lib/perl/Big/Dummy.pm', 'different install exists' ); - - local @INC = ('install-test/lib/perl'); - local $ENV{PERL5LIB} = ''; - install( { 'blib/lib' => 'install-test/other_lib/perl', - read => 'install-test/packlist', - write => 'install-test/packlist' - }, - 0, 0, 0); - ok( -d 'install-test/other_lib/perl', 'install made other dir' ); - ok( -r 'install-test/other_lib/perl/Big/Dummy.pm', ' .pm file installed' ); - ok( -r 'install-test/packlist', ' packlist exists' ); - ok( -r 'install-test/lib/perl/Big/Dummy.pm', - ' UNINST=0 left different' ); -} - -# Test UNINST=1 only warning when failing to remove an irrelevent shadow file -{ - my $tfile='install-test/lib/perl/Big/Dummy.pm'; - local $ExtUtils::Install::Testing = $tfile; - local @INC = ('install-test/other_lib/perl','install-test/lib/perl'); - local $ENV{PERL5LIB} = ''; - ok( -r $tfile, 'different install exists' ); - my @warn; - local $SIG{__WARN__}=sub { push @warn, @_; return }; - my $ok=eval { - install( { 'blib/lib' => 'install-test/other_lib/perl', - read => 'install-test/packlist', - write => 'install-test/packlist' - }, - 0, 0, 1); - 1 - }; - ok($ok,' we didnt die'); - ok(0+@warn," we did warn"); - ok( -d 'install-test/other_lib/perl', 'install made other dir' ); - ok( -r 'install-test/other_lib/perl/Big/Dummy.pm', ' .pm file installed' ); - ok( -r 'install-test/packlist', ' packlist exists' ); - ok( -r $tfile, ' UNINST=1 failed to remove different' ); - -} - -# Test UNINST=1 dieing when failing to remove an relevent shadow file -{ - my $tfile='install-test/lib/perl/Big/Dummy.pm'; - local $ExtUtils::Install::Testing = $tfile; - local @INC = ('install-test/lib/perl','install-test/other_lib/perl'); - local $ENV{PERL5LIB} = ''; - ok( -r $tfile, 'different install exists' ); - my @warn; - local $SIG{__WARN__}=sub { push @warn,@_; return }; - my $ok=eval { - install( { 'blib/lib' => 'install-test/other_lib/perl', - read => 'install-test/packlist', - write => 'install-test/packlist' - }, - 0, 0, 1); - 1 - }; - ok(!$ok,' we did die'); - ok(!@warn," we didnt warn"); - ok( -d 'install-test/other_lib/perl', 'install made other dir' ); - ok( -r 'install-test/other_lib/perl/Big/Dummy.pm', ' .pm file installed' ); - ok( -r 'install-test/packlist', ' packlist exists' ); - ok( -r $tfile,' UNINST=1 failed to remove different' ); -} - -# Test UNINST=1 removing other versions in other dirs. -{ - local @INC = ('install-test/lib/perl'); - local $ENV{PERL5LIB} = ''; - install( { 'blib/lib' => 'install-test/other_lib/perl', - read => 'install-test/packlist', - write => 'install-test/packlist' - }, - 0, 0, 1); - ok( -d 'install-test/other_lib/perl', 'install made other dir' ); - ok( -r 'install-test/other_lib/perl/Big/Dummy.pm', ' .pm file installed' ); - ok( -r 'install-test/packlist', ' packlist exists' ); - ok( !-r 'install-test/lib/perl/Big/Dummy.pm', - ' UNINST=1 removed different' ); -} - diff --git a/lib/ExtUtils/t/InstallWithMM.t b/lib/ExtUtils/t/InstallWithMM.t deleted file mode 100644 index 354b8f4d35..0000000000 --- a/lib/ExtUtils/t/InstallWithMM.t +++ /dev/null @@ -1,95 +0,0 @@ -#!/usr/bin/perl -w - -# Make sure EUI works with MakeMaker - -BEGIN { - if( $ENV{PERL_CORE} ) { - chdir 't' if -d 't'; - @INC = ('../lib', 'lib'); - } - else { - unshift @INC, 't/lib'; - } -} - -use strict; -use Config; -use ExtUtils::MakeMaker; - -use Test::More tests => 15; -use MakeMaker::Test::Utils; -use MakeMaker::Test::Setup::BFD; -use File::Find; -use File::Spec; -use File::Path; - -my $make = make_run(); - -# Environment variables which interfere with our testing. -delete @ENV{qw(PREFIX LIB MAKEFLAGS)}; - -# Run Makefile.PL -{ - my $perl = which_perl(); - my $Is_VMS = $^O eq 'VMS'; - - chdir 't'; - - perl_lib; - - my $Touch_Time = calibrate_mtime(); - - $| = 1; - - ok( setup_recurs(), 'setup' ); - END { - ok( chdir File::Spec->updir ); - ok( teardown_recurs(), 'teardown' ); - } - - ok( chdir('Big-Dummy'), "chdir'd to Big-Dummy" ) || - diag("chdir failed: $!"); - - my @mpl_out = run(qq{$perl Makefile.PL "PREFIX=../dummy-install"}); - END { rmtree '../dummy-install'; } - - cmp_ok( $?, '==', 0, 'Makefile.PL exited with zero' ) || - diag(@mpl_out); - - END { unlink makefile_name(), makefile_backup() } -} - - -# make -{ - my $make_out = run($make); - is( $?, 0, 'make ran ok' ) || - diag($make_out); -} - - -# Test 'make install VERBINST=1' -{ - my $make_install_verbinst = make_macro($make, 'install', VERBINST => 1); - my $install_out = run($make_install_verbinst); - is( $?, 0, 'install' ) || diag $install_out; - like( $install_out, qr/^Installing /m ); - like( $install_out, qr/^Writing /m ); - - ok( -r '../dummy-install', ' install dir created' ); - my %files = (); - find( sub { - # do it case-insensitive for non-case preserving OSs - my $file = lc $_; - - # VMS likes to put dots on the end of things that don't have them. - $file =~ s/\.$// if $Is_VMS; - - $files{$file} = $File::Find::name; - }, '../dummy-install' ); - ok( $files{'dummy.pm'}, ' Dummy.pm installed' ); - ok( $files{'liar.pm'}, ' Liar.pm installed' ); - ok( $files{'program'}, ' program installed' ); - ok( $files{'.packlist'}, ' packlist created' ); - ok( $files{'perllocal.pod'},' perllocal.pod created' ); -} diff --git a/lib/ExtUtils/t/Installapi2.t b/lib/ExtUtils/t/Installapi2.t deleted file mode 100644 index c59b8abb38..0000000000 --- a/lib/ExtUtils/t/Installapi2.t +++ /dev/null @@ -1,238 +0,0 @@ -#!/usr/bin/perl -w - -# Test ExtUtils::Install. - -BEGIN { - if( $ENV{PERL_CORE} ) { - @INC = ('../../lib', '../lib', 'lib'); - } - else { - unshift @INC, 't/lib'; - } -} -chdir 't'; - -use strict; -use TieOut; -use File::Path; -use File::Spec; - -use Test::More tests => 70; - -use MakeMaker::Test::Setup::BFD; - -BEGIN { use_ok('ExtUtils::Install') } - -# Check exports. -foreach my $func (qw(install uninstall pm_to_blib install_default)) { - can_ok(__PACKAGE__, $func); -} - - -ok( setup_recurs(), 'setup' ); -END { - ok( chdir File::Spec->updir ); - ok( teardown_recurs(), 'teardown' ); -} -# ensure the env doesnt pollute our tests -local $ENV{EU_INSTALL_ALWAYS_COPY}; -local $ENV{EU_ALWAYS_COPY}; - -chdir 'Big-Dummy'; - -my $stdout = tie *STDOUT, 'TieOut'; -pm_to_blib( { 'lib/Big/Dummy.pm' => 'blib/lib/Big/Dummy.pm' }, - 'blib/lib/auto' - ); -END { rmtree 'blib' } - -ok( -d 'blib/lib', 'pm_to_blib created blib dir' ); -ok( -r 'blib/lib/Big/Dummy.pm', ' copied .pm file' ); -ok( -r 'blib/lib/auto', ' created autosplit dir' ); -is( $stdout->read, "cp lib/Big/Dummy.pm blib/lib/Big/Dummy.pm\n" ); - -pm_to_blib( { 'lib/Big/Dummy.pm' => 'blib/lib/Big/Dummy.pm' }, - 'blib/lib/auto' - ); -ok( -d 'blib/lib', 'second run, blib dir still there' ); -ok( -r 'blib/lib/Big/Dummy.pm', ' .pm file still there' ); -ok( -r 'blib/lib/auto', ' autosplit still there' ); -is( $stdout->read, "Skip blib/lib/Big/Dummy.pm (unchanged)\n" ); - -install( [ - from_to=>{ 'blib/lib' => 'install-test/lib/perl', - read => 'install-test/packlist', - write => 'install-test/packlist' - }, - dry_run=>1]); -ok( ! -d 'install-test/lib/perl', 'install made dir (dry run)'); -ok( ! -r 'install-test/lib/perl/Big/Dummy.pm', - ' .pm file installed (dry run)'); -ok( ! -r 'install-test/packlist', ' packlist exists (dry run)'); - -install([ from_to=> { 'blib/lib' => 'install-test/lib/perl', - read => 'install-test/packlist', - write => 'install-test/packlist' - } ]); -ok( -d 'install-test/lib/perl', 'install made dir' ); -ok( -r 'install-test/lib/perl/Big/Dummy.pm', ' .pm file installed' ); -ok(!-r 'install-test/lib/perl/Big/Dummy.SKIP', ' ignored .SKIP file' ); -ok( -r 'install-test/packlist', ' packlist exists' ); - -open(PACKLIST, 'install-test/packlist' ); -my %packlist = map { chomp; ($_ => 1) } <PACKLIST>; -close PACKLIST; - -# On case-insensitive filesystems (ie. VMS), the keys of the packlist might -# be lowercase. :( -my $native_dummy = File::Spec->catfile(qw(install-test lib perl Big Dummy.pm)); -is( keys %packlist, 1 ); -is( lc((keys %packlist)[0]), lc $native_dummy, 'packlist written' ); - - -# Test UNINST=1 preserving same versions in other dirs. -install([from_to=> { 'blib/lib' => 'install-test/other_lib/perl', - read => 'install-test/packlist', - write => 'install-test/packlist' - },uninstall_shadows=>1]); -ok( -d 'install-test/other_lib/perl', 'install made other dir' ); -ok( -r 'install-test/other_lib/perl/Big/Dummy.pm', ' .pm file installed' ); -ok( -r 'install-test/packlist', ' packlist exists' ); -ok( -r 'install-test/lib/perl/Big/Dummy.pm', ' UNINST=1 preserved same' ); - - -chmod 0644, 'blib/lib/Big/Dummy.pm' or die $!; -open(DUMMY, ">>blib/lib/Big/Dummy.pm") or die $!; -print DUMMY "Extra stuff\n"; -close DUMMY; - - -# Test UNINST=0 does not remove other versions in other dirs. -{ - ok( -r 'install-test/lib/perl/Big/Dummy.pm', 'different install exists' ); - - local @INC = ('install-test/lib/perl'); - local $ENV{PERL5LIB} = ''; - install([from_to=> { 'blib/lib' => 'install-test/other_lib/perl', - read => 'install-test/packlist', - write => 'install-test/packlist' - }]); - ok( -d 'install-test/other_lib/perl', 'install made other dir' ); - ok( -r 'install-test/other_lib/perl/Big/Dummy.pm', ' .pm file installed' ); - ok( -r 'install-test/packlist', ' packlist exists' ); - ok( -r 'install-test/lib/perl/Big/Dummy.pm', - ' UNINST=0 left different' ); -} - -# Test UNINST=1 only warning when failing to remove an irrelevent shadow file -{ - my $tfile='install-test/lib/perl/Big/Dummy.pm'; - local $ExtUtils::Install::Testing = $tfile; - local @INC = ('install-test/other_lib/perl','install-test/lib/perl'); - local $ENV{PERL5LIB} = ''; - ok( -r $tfile, 'different install exists' ); - my @warn; - local $SIG{__WARN__}=sub { push @warn, @_; return }; - my $ok=eval { - install([from_to=> { 'blib/lib' => 'install-test/other_lib/perl', - read => 'install-test/packlist', - write => 'install-test/packlist' - }, - uninstall_shadows=>1]); - 1 - }; - ok($ok,' we didnt die'); - ok(0+@warn," we did warn"); - ok( -d 'install-test/other_lib/perl', 'install made other dir' ); - ok( -r 'install-test/other_lib/perl/Big/Dummy.pm', ' .pm file installed' ); - ok( -r 'install-test/packlist', ' packlist exists' ); - ok( -r $tfile, ' UNINST=1 failed to remove different' ); - -} - -# Test UNINST=1 dieing when failing to remove an relevent shadow file -{ - my $tfile='install-test/lib/perl/Big/Dummy.pm'; - local $ExtUtils::Install::Testing = $tfile; - local @INC = ('install-test/lib/perl','install-test/other_lib/perl'); - local $ENV{PERL5LIB} = ''; - ok( -r $tfile, 'different install exists' ); - my @warn; - local $SIG{__WARN__}=sub { push @warn,@_; return }; - my $ok=eval { - install([from_to=> { 'blib/lib' => 'install-test/other_lib/perl', - read => 'install-test/packlist', - write => 'install-test/packlist' - },uninstall_shadows=>1]); - 1 - }; - ok(!$ok,' we did die'); - ok(!@warn," we didnt warn"); - ok( -d 'install-test/other_lib/perl', 'install made other dir' ); - ok( -r 'install-test/other_lib/perl/Big/Dummy.pm', ' .pm file installed' ); - ok( -r 'install-test/packlist', ' packlist exists' ); - ok( -r $tfile,' UNINST=1 failed to remove different' ); -} - -# Test UNINST=1 removing other versions in other dirs. -{ - local @INC = ('install-test/lib/perl'); - local $ENV{PERL5LIB} = ''; - ok( -r 'install-test/lib/perl/Big/Dummy.pm','different install exists' ); - install([from_to=>{ 'blib/lib' => 'install-test/other_lib/perl', - read => 'install-test/packlist', - write => 'install-test/packlist' - },uninstall_shadows=>1]); - ok( -d 'install-test/other_lib/perl', 'install made other dir' ); - ok( -r 'install-test/other_lib/perl/Big/Dummy.pm', ' .pm file installed' ); - ok( -r 'install-test/packlist', ' packlist exists' ); - ok( !-r 'install-test/lib/perl/Big/Dummy.pm', - ' UNINST=1 removed different' ); -} - -# Test EU_ALWAYS_COPY triggers copy. -{ - local @INC = ('install-test/lib/perl'); - local $ENV{PERL5LIB} = ''; - local $ENV{EU_INSTALL_ALWAYS_COPY}=1; - my $tfile='install-test/other_lib/perl/Big/Dummy.pm'; - my $sfile='blib/lib/Big/Dummy.pm'; - ok(-r $tfile,"install file already exists"); - ok(-r $sfile,"source file already exists"); - utime time-600, time-600, $sfile or die "utime '$sfile' failed:$!"; - ok( (stat $tfile)[9]!=(stat $sfile)[9],' Times are different'); - install([from_to=>{ 'blib/lib' => 'install-test/other_lib/perl', - read => 'install-test/packlist', - write => 'install-test/packlist' - },result=>\my %result]); - ok( -d 'install-test/other_lib/perl', 'install made other dir' ); - ok( -r 'install-test/other_lib/perl/Big/Dummy.pm', ' .pm file installed' ); - ok( -r 'install-test/packlist', ' packlist exists' ); -SKIP: { - skip "Times not preserved during copy by default", 1 if $^O eq 'VMS'; - ok( (stat $tfile)[9]==(stat $sfile)[9],' Times are same'); -} - ok( !$result{install_unchanged},' $result{install_unchanged} should be empty'); -} -# Test nothing is copied. -{ - local @INC = ('install-test/lib/perl'); - local $ENV{PERL5LIB} = ''; - local $ENV{EU_INSTALL_ALWAYS_COPY}=0; - my $tfile='install-test/other_lib/perl/Big/Dummy.pm'; - my $sfile='blib/lib/Big/Dummy.pm'; - ok(-r $tfile,"install file already exists"); - ok(-r $sfile,"source file already exists"); - utime time-1200, time-1200, $sfile or die "utime '$sfile' failed:$!"; - ok( (stat $tfile)[9]!=(stat $sfile)[9],' Times are different'); - install([from_to=>{ 'blib/lib' => 'install-test/other_lib/perl', - read => 'install-test/packlist', - write => 'install-test/packlist' - },result=>\my %result]); - ok( -d 'install-test/other_lib/perl', 'install made other dir' ); - ok( -r 'install-test/other_lib/perl/Big/Dummy.pm', ' .pm file installed' ); - ok( -r 'install-test/packlist', ' packlist exists' ); - ok( (stat $tfile)[9]!=(stat$sfile)[9],' Times are different'); - ok( !$result{install},' nothing should have been installed'); - ok( $result{install_unchanged},' install_unchanged should be populated'); -} diff --git a/lib/ExtUtils/t/Installed.t b/lib/ExtUtils/t/Installed.t deleted file mode 100644 index dd492c2d1d..0000000000 --- a/lib/ExtUtils/t/Installed.t +++ /dev/null @@ -1,313 +0,0 @@ -#!/usr/bin/perl -w - -BEGIN { - if( $ENV{PERL_CORE} ) { - chdir 't' if -d 't'; - @INC = '../lib'; - } - else { - unshift @INC, 't/lib/'; - } -} -chdir 't'; - -my $Is_VMS = $^O eq 'VMS'; - -use strict; - -use Config; -use Cwd; -use File::Path; -use File::Basename; -use File::Spec; - -use Test::More tests => 63; - -BEGIN { use_ok( 'ExtUtils::Installed' ) } - -my $mandirs = !!$Config{man1direxp} + !!$Config{man3direxp}; - -# saves having to qualify package name for class methods -my $ei = bless( {}, 'ExtUtils::Installed' ); - -# Make sure meta info is available -$ei->{':private:'}{Config} = \%Config; -$ei->{':private:'}{INC} = \@INC; - -# _is_prefix -ok( $ei->_is_prefix('foo/bar', 'foo'), - '_is_prefix() should match valid path prefix' ); -ok( !$ei->_is_prefix('\foo\bar', '\bar'), - '... should not match wrong prefix' ); - -# _is_type -ok( $ei->_is_type(0, 'all'), '_is_type() should be true for type of "all"' ); - -foreach my $path (qw( man1dir man3dir )) { - SKIP: { - my $dir = File::Spec->canonpath($Config{$path.'exp'}); - skip("no man directory $path on this system", 2 ) unless $dir; - - my $file = $dir . '/foo'; - ok( $ei->_is_type($file, 'doc'), "... should find doc file in $path" ); - ok( !$ei->_is_type($file, 'prog'), "... but not prog file in $path" ); - } -} - -# VMS 5.6.1 doesn't seem to have $Config{prefixexp} -my $prefix = $Config{prefix} || $Config{prefixexp}; - -# You can concatenate /foo but not foo:, which defaults in the current -# directory -$prefix = VMS::Filespec::unixify($prefix) if $Is_VMS; - -# ActivePerl 5.6.1/631 has $Config{prefixexp} as 'p:' for some reason -$prefix = $Config{prefix} if $prefix eq 'p:' && $^O eq 'MSWin32'; - -ok( $ei->_is_type( File::Spec->catfile($prefix, 'bar'), 'prog'), - "... should find prog file under $prefix" ); - -SKIP: { - skip('no man directories on this system', 1) unless $mandirs; - is( $ei->_is_type('bar', 'doc'), 0, - '... should not find doc file outside path' ); -} - -ok( !$ei->_is_type('bar', 'prog'), - '... nor prog file outside path' ); -ok( !$ei->_is_type('whocares', 'someother'), '... nor other type anywhere' ); - -# _is_under -ok( $ei->_is_under('foo'), '_is_under() should return true with no dirs' ); - -my @under = qw( boo bar baz ); -ok( !$ei->_is_under('foo', @under), '... should find no file not under dirs'); -ok( $ei->_is_under('baz', @under), '... should find file under dir' ); - - -rmtree 'auto/FakeMod'; -ok( mkpath('auto/FakeMod') ); -END { rmtree 'auto' } - -ok(open(PACKLIST, '>auto/FakeMod/.packlist')); -print PACKLIST 'list'; -close PACKLIST; - -ok(open(FAKEMOD, '>auto/FakeMod/FakeMod.pm')); - -print FAKEMOD <<'FAKE'; -package FakeMod; -use vars qw( $VERSION ); -$VERSION = '1.1.1'; -1; -FAKE - -close FAKEMOD; - -my $fake_mod_dir = File::Spec->catdir(cwd(), 'auto', 'FakeMod'); -{ - # 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() - push @INC, $fake_mod_dir; - - my $realei = ExtUtils::Installed->new(); - 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; - local *ExtUtils::Installed::Config; - %ExtUtils::Installed::Config = ( - %Config, - archlibexp => cwd(), - sitearchexp => cwd(), - ); - - my $realei = ExtUtils::Installed->new(); - 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 using PERL5LIB' - ); - isa_ok( $realei->{FakeMod}{packlist}, 'ExtUtils::Packlist' ); - is( $realei->{FakeMod}{version}, '1.1.1', - '... should find version in modules' ); -} - -# Do the same thing as the last block, but with overrides for -# %Config and @INC. -{ - my $config_override = { %Config::Config }; - $config_override->{archlibexp} = cwd(); - $config_override->{sitearchexp} = $fake_mod_dir; - $config_override->{version} = 'fake_test_version'; - - my @inc_override = (@INC, $fake_mod_dir); - - my $realei = ExtUtils::Installed->new( - 'config_override' => $config_override, - 'inc_override' => \@inc_override, - ); - isa_ok( $realei, 'ExtUtils::Installed' ); - isa_ok( $realei->{Perl}{packlist}, 'ExtUtils::Packlist' ); - is( $realei->{Perl}{version}, 'fake_test_version', - 'new(config_override => HASH) overrides %Config' ); - - ok( exists $realei->{FakeMod}, 'new() with overrides should find modules with .packlists'); - isa_ok( $realei->{FakeMod}{packlist}, 'ExtUtils::Packlist' ); - is( $realei->{FakeMod}{version}, '1.1.1', - '... should find version in modules' ); -} - -# Check if extra_libs works. -{ - my $realei = ExtUtils::Installed->new( - 'extra_libs' => [ cwd() ], - ); - isa_ok( $realei, 'ExtUtils::Installed' ); - isa_ok( $realei->{Perl}{packlist}, 'ExtUtils::Packlist' ); - ok( exists $realei->{FakeMod}, - 'new() with extra_libs should find modules with .packlists'); - - #{ use Data::Dumper; local $realei->{':private:'}{Config}; - # warn Dumper($realei); } - - isa_ok( $realei->{FakeMod}{packlist}, 'ExtUtils::Packlist' ); - is( $realei->{FakeMod}{version}, '1.1.1', - '... should find version in modules' ); -} - -# modules -$ei->{$_} = 1 for qw( abc def ghi ); -is( join(' ', $ei->modules()), 'abc def ghi', - 'modules() should return sorted keys' ); - -# This didn't work for a long time due to a sort in scalar context oddity. -is( $ei->modules, 3, 'modules() in scalar context' ); - -# files -$ei->{goodmod} = { - packlist => { - ($Config{man1direxp} ? - (File::Spec->catdir($Config{man1direxp}, 'foo') => 1) : - ()), - ($Config{man3direxp} ? - (File::Spec->catdir($Config{man3direxp}, 'bar') => 1) : - ()), - File::Spec->catdir($prefix, 'foobar') => 1, - foobaz => 1, - }, -}; - -eval { $ei->files('badmod') }; -like( $@, qr/badmod is not installed/,'files() should croak given bad modname'); -eval { $ei->files('goodmod', 'badtype' ) }; -like( $@, qr/type must be/,'files() should croak given bad type' ); - -my @files; -SKIP: { - skip('no man directory man1dir on this system', 2) - unless $Config{man1direxp}; - @files = $ei->files('goodmod', 'doc', $Config{man1direxp}); - is( scalar @files, 1, '... should find doc file under given dir' ); - is( (grep { /foo$/ } @files), 1, '... checking file name' ); -} -SKIP: { - skip('no man directories on this system', 1) unless $mandirs; - @files = $ei->files('goodmod', 'doc'); - is( scalar @files, $mandirs, '... should find all doc files with no dir' ); -} - -@files = $ei->files('goodmod', 'prog', 'fake', 'fake2'); -is( scalar @files, 0, '... should find no doc files given wrong dirs' ); -@files = $ei->files('goodmod', 'prog'); -is( scalar @files, 1, '... should find doc file in correct dir' ); -like( $files[0], qr/foobar[>\]]?$/, '... checking file name' ); -@files = $ei->files('goodmod'); -is( scalar @files, 2 + $mandirs, '... should find all files with no type specified' ); -my %dirnames = map { lc($_) => dirname($_) } @files; - -# directories -my @dirs = $ei->directories('goodmod', 'prog', 'fake'); -is( scalar @dirs, 0, 'directories() should return no dirs if no files found' ); - -SKIP: { - skip('no man directories on this system', 1) unless $mandirs; - @dirs = $ei->directories('goodmod', 'doc'); - is( scalar @dirs, $mandirs, '... should find all files files() would' ); -} -@dirs = $ei->directories('goodmod'); -is( scalar @dirs, 2 + $mandirs, '... should find all files files() would, again' ); -@files = sort map { exists $dirnames{lc($_)} ? $dirnames{lc($_)} : '' } @files; -is( join(' ', @files), join(' ', @dirs), '... should sort output' ); - -# directory_tree -my $expectdirs = - ($mandirs == 2) && - (dirname($Config{man1direxp}) eq dirname($Config{man3direxp})) - ? 3 : 2; - -SKIP: { - skip('no man directories on this system', 1) unless $mandirs; - @dirs = $ei->directory_tree('goodmod', 'doc', $Config{man1direxp} ? - dirname($Config{man1direxp}) : dirname($Config{man3direxp})); - is( scalar @dirs, $expectdirs, - 'directory_tree() should report intermediate dirs to those requested' ); -} - -my $fakepak = Fakepak->new(102); - -$ei->{yesmod} = { - version => 101, - packlist => $fakepak, -}; - -# these should all croak -foreach my $sub (qw( validate packlist version )) { - eval { $ei->$sub('nomod') }; - like( $@, qr/nomod is not installed/, - "$sub() should croak when asked about uninstalled module" ); -} - -# validate -is( $ei->validate('yesmod'), 'validated', - 'validate() should return results of packlist validate() call' ); - -# packlist -is( ${ $ei->packlist('yesmod') }, 102, - 'packlist() should report installed mod packlist' ); - -# version -is( $ei->version('yesmod'), 101, - 'version() should report installed mod version' ); - - -package Fakepak; - -sub new { - my $class = shift; - bless(\(my $scalar = shift), $class); -} - -sub validate { - return 'validated' -} diff --git a/lib/ExtUtils/t/Packlist.t b/lib/ExtUtils/t/Packlist.t deleted file mode 100644 index cb73e00d14..0000000000 --- a/lib/ExtUtils/t/Packlist.t +++ /dev/null @@ -1,174 +0,0 @@ -#!/usr/bin/perl -w - -BEGIN { - if( $ENV{PERL_CORE} ) { - chdir 't' if -d 't'; - @INC = '../lib'; - } - else { - unshift @INC, 't/lib'; - } -} -chdir 't'; - -use Test::More tests => 34; - -use_ok( 'ExtUtils::Packlist' ); - -is( ref(ExtUtils::Packlist::mkfh()), 'GLOB', 'mkfh() should return a FH' ); - -# new calls tie() -my $pl = ExtUtils::Packlist->new(); -isa_ok( $pl, 'ExtUtils::Packlist' ); -is( ref tied %$pl, 'ExtUtils::Packlist', 'obj should be tied underneath' ); - - -$pl = ExtUtils::Packlist::TIEHASH( 'tieclass', 'packfile' ); -is( ref($pl), 'tieclass', 'TIEHASH() should bless into class' ); -is( $pl->{packfile}, 'packfile', 'TIEHASH() should store packfile name' ); - - -ExtUtils::Packlist::STORE($pl, 'key', 'value'); -is( $pl->{data}{key}, 'value', 'STORE() should stuff stuff in data member' ); - - -$pl->{data}{foo} = 'bar'; -is( ExtUtils::Packlist::FETCH($pl, 'foo'), 'bar', 'check FETCH()' ); - - -# test FIRSTKEY and NEXTKEY -SKIP: { - $pl->{data}{bar} = 'baz'; - skip('not enough keys to test FIRSTKEY', 2) - unless keys %{ $pl->{data} } > 2; - - # get the first and second key - my ($first, $second) = keys %{ $pl->{data} }; - - # now get a couple of extra keys, to mess with the hash iterator - my $i = 0; - for (keys %{ $pl->{data} } ) { - last if $i++; - } - - # finally, see if it really can get the first key again - is( ExtUtils::Packlist::FIRSTKEY($pl), $first, - 'FIRSTKEY() should be consistent' ); - - is( ExtUtils::Packlist::NEXTKEY($pl), $second, - 'and NEXTKEY() should also be consistent' ); -} - - -ok( ExtUtils::Packlist::EXISTS($pl, 'bar'), 'EXISTS() should find keys' ); - - -ExtUtils::Packlist::DELETE($pl, 'bar'); -ok( !(exists $pl->{data}{bar}), 'DELETE() should delete cleanly' ); - - -ExtUtils::Packlist::CLEAR($pl); -is( keys %{ $pl->{data} }, 0, 'CLEAR() should wipe out data' ); - - -# DESTROY does nothing... -can_ok( 'ExtUtils::Packlist', 'DESTROY' ); - - -# write is a little more complicated -eval { ExtUtils::Packlist::write({}) }; -like( $@, qr/No packlist filename/, 'write() should croak without packfile' ); - -eval { ExtUtils::Packlist::write({}, 'eplist') }; -my $file_is_ready = $@ ? 0 : 1; -ok( $file_is_ready, 'write() can write a file' ); - -local *IN; - -SKIP: { - skip('cannot write files, some tests difficult', 3) unless $file_is_ready; - - # set this file to read-only - chmod 0444, 'eplist'; - - SKIP: { - skip("cannot write readonly files", 1) if -w 'eplist'; - - eval { ExtUtils::Packlist::write({}, 'eplist') }; - like( $@, qr/Can't open file/, 'write() should croak on open failure' ); - } - - #'now set it back (tick here fixes vim syntax highlighting ;) - chmod 0777, 'eplist'; - - # and some test data to be read - $pl->{data} = { - single => 1, - hash => { - foo => 'bar', - baz => 'bup', - }, - '/./abc' => '', - }; - eval { ExtUtils::Packlist::write($pl, 'eplist') }; - is( $@, '', 'write() should normally succeed' ); - is( $pl->{packfile}, 'eplist', 'write() should set packfile name' ); - - $file_is_ready = open(IN, 'eplist'); -} - - -eval { ExtUtils::Packlist::read({}) }; -like( $@, qr/^No packlist filename/, 'read() should croak without packfile' ); - - -eval { ExtUtils::Packlist::read({}, 'abadfilename') }; -like( $@, qr/^Can't open file/, 'read() should croak with bad packfile name' ); -#'open packfile for reading - - -# and more read() tests -SKIP: { - skip("cannot open file for reading: $!", 5) unless $file_is_ready; - my $file = do { local $/ = <IN> }; - - like( $file, qr/single\n/, 'key with value should be available' ); - like( $file, qr!/\./abc\n!, 'key with no value should also be present' ); - like( $file, qr/hash.+baz=bup/, 'key with hash value should be present' ); - like( $file, qr/hash.+foo=bar/, 'second embedded hash value should appear'); - close IN; - - eval{ ExtUtils::Packlist::read($pl, 'eplist') }; - is( $@, '', 'read() should normally succeed' ); - is( $pl->{data}{single}, undef, 'single keys should have undef value' ); - is( ref($pl->{data}{hash}), 'HASH', 'multivalue keys should become hashes'); - - is( $pl->{data}{hash}{foo}, 'bar', 'hash values should be set' ); - ok( exists $pl->{data}{'/abc'}, 'read() should resolve /./ to / in keys' ); - - # give validate a valid and an invalid file to find - $pl->{data} = { - eplist => 1, - fake => undef, - }; - - is( ExtUtils::Packlist::validate($pl), 1, - 'validate() should find missing files' ); - ExtUtils::Packlist::validate($pl, 1); - ok( !exists $pl->{data}{fake}, - 'validate() should remove missing files when prompted' ); - - # one more new() test, to see if it calls read() successfully - $pl = ExtUtils::Packlist->new('eplist'); -} - - -# packlist_file, $pl should be set from write test -is( ExtUtils::Packlist::packlist_file({ packfile => 'pl' }), 'pl', - 'packlist_file() should fetch packlist from passed hash' ); -is( ExtUtils::Packlist::packlist_file($pl), 'eplist', - 'packlist_file() should fetch packlist from ExtUtils::Packlist object' ); - -END { - 1 while unlink qw( eplist ); -} diff --git a/lib/ExtUtils/t/can_write_dir.t b/lib/ExtUtils/t/can_write_dir.t deleted file mode 100644 index be6fb1896d..0000000000 --- a/lib/ExtUtils/t/can_write_dir.t +++ /dev/null @@ -1,61 +0,0 @@ -#!/usr/bin/perl -w - -# Test the private _can_write_dir() function. - -use strict; -use ExtUtils::Install; -use File::Spec; -{ package FS; our @ISA = qw(File::Spec); } - -# Alias it for easier access -*can_write_dir = \&ExtUtils::Install::_can_write_dir; - -use Test::More 'no_plan'; - - -my $dne = FS->catdir(qw(does not exist)); -ok ! -e $dne; -is_deeply [can_write_dir($dne)], - [1, - FS->curdir, - FS->catdir('does'), - FS->catdir('does', 'not'), - FS->catdir('does', 'not', 'exist') - ]; - - -my $abs_dne = FS->rel2abs($dne); -ok ! -e $abs_dne; -is_deeply [can_write_dir($abs_dne)], - [1, - FS->rel2abs(FS->curdir), - FS->rel2abs(FS->catdir('does')), - FS->rel2abs(FS->catdir('does', 'not')), - FS->rel2abs(FS->catdir('does', 'not', 'exist')), - ]; - -SKIP: { - my $exists = FS->catdir(qw(exists)); - my $subdir = FS->catdir(qw(exists subdir)); - - - ok mkdir $exists; - END { rmdir $exists } - - ok chmod 0555, $exists, 'make read only'; - - skip "Current user or OS cannot create directories that they cannot read", 6 - if -w $exists; # these tests require a directory we cant read - - is_deeply [can_write_dir($exists)], [0, $exists]; - is_deeply [can_write_dir($subdir)], [0, $exists, $subdir]; - - ok chmod 0777, $exists, 'make writable'; - ok -w $exists; - is_deeply [can_write_dir($exists)], [1, $exists]; - is_deeply [can_write_dir($subdir)], - [1, - $exists, - $subdir - ]; -}
\ No newline at end of file |