3 # Test ExtUtils::Install.
6 if( $ENV{PERL_CORE} ) {
7 @INC = ('../../lib', '../lib', 'lib');
10 unshift @INC, 't/lib';
20 use Test::More tests => 52;
22 use MakeMaker::Test::Setup::BFD;
24 BEGIN { use_ok('ExtUtils::Install') }
25 # ensure the env doesnt pollute our tests
26 local $ENV{EU_INSTALL_ALWAYS_COPY};
27 local $ENV{EU_ALWAYS_COPY};
30 foreach my $func (qw(install uninstall pm_to_blib install_default)) {
31 can_ok(__PACKAGE__, $func);
35 ok( setup_recurs(), 'setup' );
37 ok( chdir File::Spec->updir );
38 ok( teardown_recurs(), 'teardown' );
43 my $stdout = tie *STDOUT, 'TieOut';
44 pm_to_blib( { 'lib/Big/Dummy.pm' => 'blib/lib/Big/Dummy.pm' },
49 ok( -d 'blib/lib', 'pm_to_blib created blib dir' );
50 ok( -r 'blib/lib/Big/Dummy.pm', ' copied .pm file' );
51 ok( -r 'blib/lib/auto', ' created autosplit dir' );
52 is( $stdout->read, "cp lib/Big/Dummy.pm blib/lib/Big/Dummy.pm\n" );
54 pm_to_blib( { 'lib/Big/Dummy.pm' => 'blib/lib/Big/Dummy.pm' },
57 ok( -d 'blib/lib', 'second run, blib dir still there' );
58 ok( -r 'blib/lib/Big/Dummy.pm', ' .pm file still there' );
59 ok( -r 'blib/lib/auto', ' autosplit still there' );
60 is( $stdout->read, "Skip blib/lib/Big/Dummy.pm (unchanged)\n" );
62 install( { 'blib/lib' => 'install-test/lib/perl',
63 read => 'install-test/packlist',
64 write => 'install-test/packlist'
67 ok( ! -d 'install-test/lib/perl', 'install made dir (dry run)');
68 ok( ! -r 'install-test/lib/perl/Big/Dummy.pm',
69 ' .pm file installed (dry run)');
70 ok( ! -r 'install-test/packlist', ' packlist exists (dry run)');
72 install( { 'blib/lib' => 'install-test/lib/perl',
73 read => 'install-test/packlist',
74 write => 'install-test/packlist'
76 ok( -d 'install-test/lib/perl', 'install made dir' );
77 ok( -r 'install-test/lib/perl/Big/Dummy.pm', ' .pm file installed' );
78 ok(!-r 'install-test/lib/perl/Big/Dummy.SKIP', ' ignored .SKIP file' );
79 ok( -r 'install-test/packlist', ' packlist exists' );
81 open(PACKLIST, 'install-test/packlist' );
82 my %packlist = map { chomp; ($_ => 1) } <PACKLIST>;
85 # On case-insensitive filesystems (ie. VMS), the keys of the packlist might
87 my $native_dummy = File::Spec->catfile(qw(install-test lib perl Big Dummy.pm));
88 is( keys %packlist, 1 );
89 is( lc((keys %packlist)[0]), lc $native_dummy, 'packlist written' );
92 # Test UNINST=1 preserving same versions in other dirs.
93 install( { 'blib/lib' => 'install-test/other_lib/perl',
94 read => 'install-test/packlist',
95 write => 'install-test/packlist'
98 ok( -d 'install-test/other_lib/perl', 'install made other dir' );
99 ok( -r 'install-test/other_lib/perl/Big/Dummy.pm', ' .pm file installed' );
100 ok( -r 'install-test/packlist', ' packlist exists' );
101 ok( -r 'install-test/lib/perl/Big/Dummy.pm', ' UNINST=1 preserved same' );
104 chmod 0644, 'blib/lib/Big/Dummy.pm' or die $!;
105 open(DUMMY, ">>blib/lib/Big/Dummy.pm") or die $!;
106 print DUMMY "Extra stuff\n";
110 # Test UNINST=0 does not remove other versions in other dirs.
112 ok( -r 'install-test/lib/perl/Big/Dummy.pm', 'different install exists' );
114 local @INC = ('install-test/lib/perl');
115 local $ENV{PERL5LIB} = '';
116 install( { 'blib/lib' => 'install-test/other_lib/perl',
117 read => 'install-test/packlist',
118 write => 'install-test/packlist'
121 ok( -d 'install-test/other_lib/perl', 'install made other dir' );
122 ok( -r 'install-test/other_lib/perl/Big/Dummy.pm', ' .pm file installed' );
123 ok( -r 'install-test/packlist', ' packlist exists' );
124 ok( -r 'install-test/lib/perl/Big/Dummy.pm',
125 ' UNINST=0 left different' );
128 # Test UNINST=1 only warning when failing to remove an irrelevent shadow file
130 my $tfile='install-test/lib/perl/Big/Dummy.pm';
131 local $ExtUtils::Install::Testing = $tfile;
132 local @INC = ('install-test/other_lib/perl','install-test/lib/perl');
133 local $ENV{PERL5LIB} = '';
134 ok( -r $tfile, 'different install exists' );
136 local $SIG{__WARN__}=sub { push @warn, @_; return };
138 install( { 'blib/lib' => 'install-test/other_lib/perl',
139 read => 'install-test/packlist',
140 write => 'install-test/packlist'
145 ok($ok,' we didnt die');
146 ok(0+@warn," we did warn");
147 ok( -d 'install-test/other_lib/perl', 'install made other dir' );
148 ok( -r 'install-test/other_lib/perl/Big/Dummy.pm', ' .pm file installed' );
149 ok( -r 'install-test/packlist', ' packlist exists' );
150 ok( -r $tfile, ' UNINST=1 failed to remove different' );
154 # Test UNINST=1 dieing when failing to remove an relevent shadow file
156 my $tfile='install-test/lib/perl/Big/Dummy.pm';
157 local $ExtUtils::Install::Testing = $tfile;
158 local @INC = ('install-test/lib/perl','install-test/other_lib/perl');
159 local $ENV{PERL5LIB} = '';
160 ok( -r $tfile, 'different install exists' );
162 local $SIG{__WARN__}=sub { push @warn,@_; return };
164 install( { 'blib/lib' => 'install-test/other_lib/perl',
165 read => 'install-test/packlist',
166 write => 'install-test/packlist'
171 ok(!$ok,' we did die');
172 ok(!@warn," we didnt warn");
173 ok( -d 'install-test/other_lib/perl', 'install made other dir' );
174 ok( -r 'install-test/other_lib/perl/Big/Dummy.pm', ' .pm file installed' );
175 ok( -r 'install-test/packlist', ' packlist exists' );
176 ok( -r $tfile,' UNINST=1 failed to remove different' );
179 # Test UNINST=1 removing other versions in other dirs.
181 local @INC = ('install-test/lib/perl');
182 local $ENV{PERL5LIB} = '';
183 install( { 'blib/lib' => 'install-test/other_lib/perl',
184 read => 'install-test/packlist',
185 write => 'install-test/packlist'
188 ok( -d 'install-test/other_lib/perl', 'install made other dir' );
189 ok( -r 'install-test/other_lib/perl/Big/Dummy.pm', ' .pm file installed' );
190 ok( -r 'install-test/packlist', ' packlist exists' );
191 ok( !-r 'install-test/lib/perl/Big/Dummy.pm',
192 ' UNINST=1 removed different' );