1*0Sstevel@tonic-gate#!/usr/bin/perl -w 2*0Sstevel@tonic-gate 3*0Sstevel@tonic-gate# Test ExtUtils::Install. 4*0Sstevel@tonic-gate 5*0Sstevel@tonic-gateBEGIN { 6*0Sstevel@tonic-gate if( $ENV{PERL_CORE} ) { 7*0Sstevel@tonic-gate @INC = ('../../lib', '../lib', 'lib'); 8*0Sstevel@tonic-gate } 9*0Sstevel@tonic-gate else { 10*0Sstevel@tonic-gate unshift @INC, 't/lib'; 11*0Sstevel@tonic-gate } 12*0Sstevel@tonic-gate} 13*0Sstevel@tonic-gatechdir 't'; 14*0Sstevel@tonic-gate 15*0Sstevel@tonic-gateuse strict; 16*0Sstevel@tonic-gateuse TieOut; 17*0Sstevel@tonic-gateuse File::Path; 18*0Sstevel@tonic-gateuse File::Spec; 19*0Sstevel@tonic-gate 20*0Sstevel@tonic-gateuse Test::More tests => 29; 21*0Sstevel@tonic-gate 22*0Sstevel@tonic-gateBEGIN { use_ok('ExtUtils::Install') } 23*0Sstevel@tonic-gate 24*0Sstevel@tonic-gate# Check exports. 25*0Sstevel@tonic-gateforeach my $func (qw(install uninstall pm_to_blib install_default)) { 26*0Sstevel@tonic-gate can_ok(__PACKAGE__, $func); 27*0Sstevel@tonic-gate} 28*0Sstevel@tonic-gate 29*0Sstevel@tonic-gate 30*0Sstevel@tonic-gatechdir 'Big-Dummy'; 31*0Sstevel@tonic-gate 32*0Sstevel@tonic-gatemy $stdout = tie *STDOUT, 'TieOut'; 33*0Sstevel@tonic-gatepm_to_blib( { 'lib/Big/Dummy.pm' => 'blib/lib/Big/Dummy.pm' }, 34*0Sstevel@tonic-gate 'blib/lib/auto' 35*0Sstevel@tonic-gate ); 36*0Sstevel@tonic-gateEND { rmtree 'blib' } 37*0Sstevel@tonic-gate 38*0Sstevel@tonic-gateok( -d 'blib/lib', 'pm_to_blib created blib dir' ); 39*0Sstevel@tonic-gateok( -r 'blib/lib/Big/Dummy.pm', ' copied .pm file' ); 40*0Sstevel@tonic-gateok( -r 'blib/lib/auto', ' created autosplit dir' ); 41*0Sstevel@tonic-gateis( $stdout->read, "cp lib/Big/Dummy.pm blib/lib/Big/Dummy.pm\n" ); 42*0Sstevel@tonic-gate 43*0Sstevel@tonic-gatepm_to_blib( { 'lib/Big/Dummy.pm' => 'blib/lib/Big/Dummy.pm' }, 44*0Sstevel@tonic-gate 'blib/lib/auto' 45*0Sstevel@tonic-gate ); 46*0Sstevel@tonic-gateok( -d 'blib/lib', 'second run, blib dir still there' ); 47*0Sstevel@tonic-gateok( -r 'blib/lib/Big/Dummy.pm', ' .pm file still there' ); 48*0Sstevel@tonic-gateok( -r 'blib/lib/auto', ' autosplit still there' ); 49*0Sstevel@tonic-gateis( $stdout->read, "Skip blib/lib/Big/Dummy.pm (unchanged)\n" ); 50*0Sstevel@tonic-gate 51*0Sstevel@tonic-gateinstall( { 'blib/lib' => 'install-test/lib/perl', 52*0Sstevel@tonic-gate read => 'install-test/packlist', 53*0Sstevel@tonic-gate write => 'install-test/packlist' 54*0Sstevel@tonic-gate }, 55*0Sstevel@tonic-gate 0, 1); 56*0Sstevel@tonic-gateok( ! -d 'install-test/lib/perl', 'install made dir (dry run)'); 57*0Sstevel@tonic-gateok( ! -r 'install-test/lib/perl/Big/Dummy.pm', 58*0Sstevel@tonic-gate ' .pm file installed (dry run)'); 59*0Sstevel@tonic-gateok( ! -r 'install-test/packlist', ' packlist exists (dry run)'); 60*0Sstevel@tonic-gate 61*0Sstevel@tonic-gateinstall( { 'blib/lib' => 'install-test/lib/perl', 62*0Sstevel@tonic-gate read => 'install-test/packlist', 63*0Sstevel@tonic-gate write => 'install-test/packlist' 64*0Sstevel@tonic-gate } ); 65*0Sstevel@tonic-gateok( -d 'install-test/lib/perl', 'install made dir' ); 66*0Sstevel@tonic-gateok( -r 'install-test/lib/perl/Big/Dummy.pm', ' .pm file installed' ); 67*0Sstevel@tonic-gateok( -r 'install-test/packlist', ' packlist exists' ); 68*0Sstevel@tonic-gate 69*0Sstevel@tonic-gateopen(PACKLIST, 'install-test/packlist' ); 70*0Sstevel@tonic-gatemy %packlist = map { chomp; ($_ => 1) } <PACKLIST>; 71*0Sstevel@tonic-gateclose PACKLIST; 72*0Sstevel@tonic-gate 73*0Sstevel@tonic-gate# On case-insensitive filesystems (ie. VMS), the keys of the packlist might 74*0Sstevel@tonic-gate# be lowercase. :( 75*0Sstevel@tonic-gatemy $native_dummy = File::Spec->catfile(qw(install-test lib perl Big Dummy.pm)); 76*0Sstevel@tonic-gateis( keys %packlist, 1 ); 77*0Sstevel@tonic-gateis( lc((keys %packlist)[0]), lc $native_dummy, 'packlist written' ); 78*0Sstevel@tonic-gate 79*0Sstevel@tonic-gate 80*0Sstevel@tonic-gate# Test UNINST=1 preserving same versions in other dirs. 81*0Sstevel@tonic-gateinstall( { 'blib/lib' => 'install-test/other_lib/perl', 82*0Sstevel@tonic-gate read => 'install-test/packlist', 83*0Sstevel@tonic-gate write => 'install-test/packlist' 84*0Sstevel@tonic-gate }, 85*0Sstevel@tonic-gate 0, 0, 1); 86*0Sstevel@tonic-gateok( -d 'install-test/other_lib/perl', 'install made other dir' ); 87*0Sstevel@tonic-gateok( -r 'install-test/other_lib/perl/Big/Dummy.pm', ' .pm file installed' ); 88*0Sstevel@tonic-gateok( -r 'install-test/packlist', ' packlist exists' ); 89*0Sstevel@tonic-gateok( -r 'install-test/lib/perl/Big/Dummy.pm', ' UNINST=1 preserved same' ); 90*0Sstevel@tonic-gate 91*0Sstevel@tonic-gate 92*0Sstevel@tonic-gate 93*0Sstevel@tonic-gate# Test UNINST=1 removing other versions in other dirs. 94*0Sstevel@tonic-gatechmod 0644, 'blib/lib/Big/Dummy.pm' or die $!; 95*0Sstevel@tonic-gateopen(DUMMY, ">>blib/lib/Big/Dummy.pm") or die $!; 96*0Sstevel@tonic-gateprint DUMMY "Extra stuff\n"; 97*0Sstevel@tonic-gateclose DUMMY; 98*0Sstevel@tonic-gate 99*0Sstevel@tonic-gate{ 100*0Sstevel@tonic-gate local @INC = ('install-test/lib/perl'); 101*0Sstevel@tonic-gate local $ENV{PERL5LIB} = ''; 102*0Sstevel@tonic-gate install( { 'blib/lib' => 'install-test/other_lib/perl', 103*0Sstevel@tonic-gate read => 'install-test/packlist', 104*0Sstevel@tonic-gate write => 'install-test/packlist' 105*0Sstevel@tonic-gate }, 106*0Sstevel@tonic-gate 0, 0, 1); 107*0Sstevel@tonic-gate ok( -d 'install-test/other_lib/perl', 'install made other dir' ); 108*0Sstevel@tonic-gate ok( -r 'install-test/other_lib/perl/Big/Dummy.pm', ' .pm file installed' ); 109*0Sstevel@tonic-gate ok( -r 'install-test/packlist', ' packlist exists' ); 110*0Sstevel@tonic-gate ok( !-r 'install-test/lib/perl/Big/Dummy.pm', 111*0Sstevel@tonic-gate ' UNINST=1 removed different' ); 112*0Sstevel@tonic-gate} 113