3 # Test ExtUtils::Install.
14 use Test::More tests => 52;
16 use MakeMaker::Test::Setup::BFD;
18 BEGIN { use_ok('ExtUtils::Install') }
19 # ensure the env doesnt pollute our tests
20 local $ENV{EU_INSTALL_ALWAYS_COPY};
21 local $ENV{EU_ALWAYS_COPY};
24 foreach my $func (qw(install uninstall pm_to_blib install_default)) {
25 can_ok(__PACKAGE__, $func);
29 ok( setup_recurs(), 'setup' );
31 ok( chdir File::Spec->updir );
32 ok( teardown_recurs(), 'teardown' );
37 my $stdout = tie *STDOUT, 'TieOut';
38 pm_to_blib( { 'lib/Big/Dummy.pm' => 'blib/lib/Big/Dummy.pm' },
43 ok( -d 'blib/lib', 'pm_to_blib created blib dir' );
44 ok( -r 'blib/lib/Big/Dummy.pm', ' copied .pm file' );
45 ok( -r 'blib/lib/auto', ' created autosplit dir' );
46 is( $stdout->read, "cp lib/Big/Dummy.pm blib/lib/Big/Dummy.pm\n" );
48 pm_to_blib( { 'lib/Big/Dummy.pm' => 'blib/lib/Big/Dummy.pm' },
51 ok( -d 'blib/lib', 'second run, blib dir still there' );
52 ok( -r 'blib/lib/Big/Dummy.pm', ' .pm file still there' );
53 ok( -r 'blib/lib/auto', ' autosplit still there' );
54 is( $stdout->read, "Skip blib/lib/Big/Dummy.pm (unchanged)\n" );
56 install( { 'blib/lib' => 'install-test/lib/perl',
57 read => 'install-test/packlist',
58 write => 'install-test/packlist'
61 ok( ! -d 'install-test/lib/perl', 'install made dir (dry run)');
62 ok( ! -r 'install-test/lib/perl/Big/Dummy.pm',
63 ' .pm file installed (dry run)');
64 ok( ! -r 'install-test/packlist', ' packlist exists (dry run)');
66 install( { 'blib/lib' => 'install-test/lib/perl',
67 read => 'install-test/packlist',
68 write => 'install-test/packlist'
70 ok( -d 'install-test/lib/perl', 'install made dir' );
71 ok( -r 'install-test/lib/perl/Big/Dummy.pm', ' .pm file installed' );
72 ok(!-r 'install-test/lib/perl/Big/Dummy.SKIP', ' ignored .SKIP file' );
73 ok( -r 'install-test/packlist', ' packlist exists' );
75 open(PACKLIST, 'install-test/packlist' );
76 my %packlist = map { chomp; ($_ => 1) } <PACKLIST>;
79 # On case-insensitive filesystems (ie. VMS), the keys of the packlist might
81 my $native_dummy = File::Spec->catfile(qw(install-test lib perl Big Dummy.pm));
82 is( keys %packlist, 1 );
83 is( lc((keys %packlist)[0]), lc $native_dummy, 'packlist written' );
86 # Test UNINST=1 preserving same versions in other dirs.
87 install( { 'blib/lib' => 'install-test/other_lib/perl',
88 read => 'install-test/packlist',
89 write => 'install-test/packlist'
92 ok( -d 'install-test/other_lib/perl', 'install made other dir' );
93 ok( -r 'install-test/other_lib/perl/Big/Dummy.pm', ' .pm file installed' );
94 ok( -r 'install-test/packlist', ' packlist exists' );
95 ok( -r 'install-test/lib/perl/Big/Dummy.pm', ' UNINST=1 preserved same' );
98 chmod 0644, 'blib/lib/Big/Dummy.pm' or die $!;
99 open(DUMMY, ">>blib/lib/Big/Dummy.pm") or die $!;
100 print DUMMY "Extra stuff\n";
104 # Test UNINST=0 does not remove other versions in other dirs.
106 ok( -r 'install-test/lib/perl/Big/Dummy.pm', 'different install exists' );
108 local @INC = ('install-test/lib/perl');
109 local $ENV{PERL5LIB} = '';
110 install( { 'blib/lib' => 'install-test/other_lib/perl',
111 read => 'install-test/packlist',
112 write => 'install-test/packlist'
115 ok( -d 'install-test/other_lib/perl', 'install made other dir' );
116 ok( -r 'install-test/other_lib/perl/Big/Dummy.pm', ' .pm file installed' );
117 ok( -r 'install-test/packlist', ' packlist exists' );
118 ok( -r 'install-test/lib/perl/Big/Dummy.pm',
119 ' UNINST=0 left different' );
122 # Test UNINST=1 only warning when failing to remove an irrelevent shadow file
124 my $tfile='install-test/lib/perl/Big/Dummy.pm';
125 local $ExtUtils::Install::Testing = $tfile;
126 local @INC = ('install-test/other_lib/perl','install-test/lib/perl');
127 local $ENV{PERL5LIB} = '';
128 ok( -r $tfile, 'different install exists' );
130 local $SIG{__WARN__}=sub { push @warn, @_; return };
132 install( { 'blib/lib' => 'install-test/other_lib/perl',
133 read => 'install-test/packlist',
134 write => 'install-test/packlist'
139 ok($ok,' we didnt die');
140 ok(0+@warn," we did warn");
141 ok( -d 'install-test/other_lib/perl', 'install made other dir' );
142 ok( -r 'install-test/other_lib/perl/Big/Dummy.pm', ' .pm file installed' );
143 ok( -r 'install-test/packlist', ' packlist exists' );
144 ok( -r $tfile, ' UNINST=1 failed to remove different' );
148 # Test UNINST=1 dieing when failing to remove an relevent shadow file
150 my $tfile='install-test/lib/perl/Big/Dummy.pm';
151 local $ExtUtils::Install::Testing = $tfile;
152 local @INC = ('install-test/lib/perl','install-test/other_lib/perl');
153 local $ENV{PERL5LIB} = '';
154 ok( -r $tfile, 'different install exists' );
156 local $SIG{__WARN__}=sub { push @warn,@_; return };
158 install( { 'blib/lib' => 'install-test/other_lib/perl',
159 read => 'install-test/packlist',
160 write => 'install-test/packlist'
165 ok(!$ok,' we did die');
166 ok(!@warn," we didnt warn");
167 ok( -d 'install-test/other_lib/perl', 'install made other dir' );
168 ok( -r 'install-test/other_lib/perl/Big/Dummy.pm', ' .pm file installed' );
169 ok( -r 'install-test/packlist', ' packlist exists' );
170 ok( -r $tfile,' UNINST=1 failed to remove different' );
173 # Test UNINST=1 removing other versions in other dirs.
175 local @INC = ('install-test/lib/perl');
176 local $ENV{PERL5LIB} = '';
177 install( { 'blib/lib' => 'install-test/other_lib/perl',
178 read => 'install-test/packlist',
179 write => 'install-test/packlist'
182 ok( -d 'install-test/other_lib/perl', 'install made other dir' );
183 ok( -r 'install-test/other_lib/perl/Big/Dummy.pm', ' .pm file installed' );
184 ok( -r 'install-test/packlist', ' packlist exists' );
185 ok( !-r 'install-test/lib/perl/Big/Dummy.pm',
186 ' UNINST=1 removed different' );