1N/A#!/usr/bin/perl -w
1N/A
1N/A# Test ExtUtils::Install.
1N/A
1N/ABEGIN {
1N/A if( $ENV{PERL_CORE} ) {
1N/A @INC = ('../../lib', '../lib', 'lib');
1N/A }
1N/A else {
1N/A unshift @INC, 't/lib';
1N/A }
1N/A}
1N/Achdir 't';
1N/A
1N/Ause strict;
1N/Ause TieOut;
1N/Ause File::Path;
1N/Ause File::Spec;
1N/A
1N/Ause Test::More tests => 29;
1N/A
1N/ABEGIN { use_ok('ExtUtils::Install') }
1N/A
1N/A# Check exports.
1N/Aforeach my $func (qw(install uninstall pm_to_blib install_default)) {
1N/A can_ok(__PACKAGE__, $func);
1N/A}
1N/A
1N/A
1N/Achdir 'Big-Dummy';
1N/A
1N/Amy $stdout = tie *STDOUT, 'TieOut';
1N/Apm_to_blib( { 'lib/Big/Dummy.pm' => 'blib/lib/Big/Dummy.pm' },
1N/A 'blib/lib/auto'
1N/A );
1N/AEND { rmtree 'blib' }
1N/A
1N/Aok( -d 'blib/lib', 'pm_to_blib created blib dir' );
1N/Aok( -r 'blib/lib/Big/Dummy.pm', ' copied .pm file' );
1N/Aok( -r 'blib/lib/auto', ' created autosplit dir' );
1N/Ais( $stdout->read, "cp lib/Big/Dummy.pm blib/lib/Big/Dummy.pm\n" );
1N/A
1N/Apm_to_blib( { 'lib/Big/Dummy.pm' => 'blib/lib/Big/Dummy.pm' },
1N/A 'blib/lib/auto'
1N/A );
1N/Aok( -d 'blib/lib', 'second run, blib dir still there' );
1N/Aok( -r 'blib/lib/Big/Dummy.pm', ' .pm file still there' );
1N/Aok( -r 'blib/lib/auto', ' autosplit still there' );
1N/Ais( $stdout->read, "Skip blib/lib/Big/Dummy.pm (unchanged)\n" );
1N/A
1N/Ainstall( { 'blib/lib' => 'install-test/lib/perl',
1N/A read => 'install-test/packlist',
1N/A write => 'install-test/packlist'
1N/A },
1N/A 0, 1);
1N/Aok( ! -d 'install-test/lib/perl', 'install made dir (dry run)');
1N/Aok( ! -r 'install-test/lib/perl/Big/Dummy.pm',
1N/A ' .pm file installed (dry run)');
1N/Aok( ! -r 'install-test/packlist', ' packlist exists (dry run)');
1N/A
1N/Ainstall( { 'blib/lib' => 'install-test/lib/perl',
1N/A read => 'install-test/packlist',
1N/A write => 'install-test/packlist'
1N/A } );
1N/Aok( -d 'install-test/lib/perl', 'install made dir' );
1N/Aok( -r 'install-test/lib/perl/Big/Dummy.pm', ' .pm file installed' );
1N/Aok( -r 'install-test/packlist', ' packlist exists' );
1N/A
1N/Aopen(PACKLIST, 'install-test/packlist' );
1N/Amy %packlist = map { chomp; ($_ => 1) } <PACKLIST>;
1N/Aclose PACKLIST;
1N/A
1N/A# On case-insensitive filesystems (ie. VMS), the keys of the packlist might
1N/A# be lowercase. :(
1N/Amy $native_dummy = File::Spec->catfile(qw(install-test lib perl Big Dummy.pm));
1N/Ais( keys %packlist, 1 );
1N/Ais( lc((keys %packlist)[0]), lc $native_dummy, 'packlist written' );
1N/A
1N/A
1N/A# Test UNINST=1 preserving same versions in other dirs.
1N/Ainstall( { 'blib/lib' => 'install-test/other_lib/perl',
1N/A read => 'install-test/packlist',
1N/A write => 'install-test/packlist'
1N/A },
1N/A 0, 0, 1);
1N/Aok( -d 'install-test/other_lib/perl', 'install made other dir' );
1N/Aok( -r 'install-test/other_lib/perl/Big/Dummy.pm', ' .pm file installed' );
1N/Aok( -r 'install-test/packlist', ' packlist exists' );
1N/Aok( -r 'install-test/lib/perl/Big/Dummy.pm', ' UNINST=1 preserved same' );
1N/A
1N/A
1N/A
1N/A# Test UNINST=1 removing other versions in other dirs.
1N/Achmod 0644, 'blib/lib/Big/Dummy.pm' or die $!;
1N/Aopen(DUMMY, ">>blib/lib/Big/Dummy.pm") or die $!;
1N/Aprint DUMMY "Extra stuff\n";
1N/Aclose DUMMY;
1N/A
1N/A{
1N/A local @INC = ('install-test/lib/perl');
1N/A local $ENV{PERL5LIB} = '';
1N/A install( { 'blib/lib' => 'install-test/other_lib/perl',
1N/A read => 'install-test/packlist',
1N/A write => 'install-test/packlist'
1N/A },
1N/A 0, 0, 1);
1N/A ok( -d 'install-test/other_lib/perl', 'install made other dir' );
1N/A ok( -r 'install-test/other_lib/perl/Big/Dummy.pm', ' .pm file installed' );
1N/A ok( -r 'install-test/packlist', ' packlist exists' );
1N/A ok( !-r 'install-test/lib/perl/Big/Dummy.pm',
1N/A ' UNINST=1 removed different' );
1N/A}