@@ -25,7 +25,7 @@ use ExtUtils::MM;
2525use Test::More
2626 !MM-> can_run(make()) && $ENV {PERL_CORE } && $Config {' usecrosscompile' }
2727 ? (skip_all => " cross-compiling and make not available" )
28- : (tests => 188 );
28+ : (tests => 195 );
2929use File::Find;
3030use File::Spec;
3131use File::Path;
@@ -186,64 +186,48 @@ open $fh, '>', $makefile;
186186print $fh $mtext ;
187187close $fh ;
188188
189- my $install_out = run(" $make install" );
190- is( $? , 0, ' install' ) || diag $install_out ;
191- like( $install_out , qr / ^Installing / m );
192-
193189sub check_dummy_inst {
194- my ($loc , $skipsubdir ) = @_ ;
195- my %files = ();
196- find( sub {
197- # do it case-insensitive for non-case preserving OSs
198- my $file = lc $_ ;
199- # VMS likes to put dots on the end of things that don't have them.
200- $file =~ s /\. $// if $Is_VMS ;
201- $files {$file } = $File::Find::name ;
202- }, $loc );
203- ok( $files {' dummy.pm' }, ' Dummy.pm installed' );
204- ok( $files {' liar.pm' }, ' Liar.pm installed' ) unless $skipsubdir ;
205- ok( $files {' program' }, ' program installed' );
206- ok( $files {' .packlist' }, ' packlist created' );
207- ok( $files {' perllocal.pod' },' perllocal.pod created' );
190+ my ($loc , $install_args , $label , $skipsubdir ) = @_ ;
191+ my %files ;
192+ SKIP: {
193+ my $install_out = run(" $make install NOECHO= $install_args " );
194+ is( $? , 0, " install $label " ) || diag $install_out ;
195+ like( $install_out , qr / ^Installing / m , " /Installing/ $label " );
196+ ok( -r $loc , " $label install dir created" )
197+ or skip " $loc doesn't exist" , 5;
198+ find( sub {
199+ # do it case-insensitive for non-case preserving OSs
200+ my $file = lc $_ ;
201+ # VMS likes to put dots on the end of things that don't have them.
202+ $file =~ s /\. $// if $Is_VMS ;
203+ $files {$file } = $File::Find::name ;
204+ }, $loc );
205+ ok( $files {' dummy.pm' }, " Dummy.pm installed $label " );
206+ if ($skipsubdir ) { ok 1 } else {
207+ ok( $files {' liar.pm' }, " Liar.pm installed $label " );
208+ }
209+ ok( $files {' program' }, " program installed $label " );
210+ ok( $files {' .packlist' }, " packlist created $label " );
211+ ok( $files {' perllocal.pod' }," perllocal.pod created $label " );
212+ }
208213 \%files ;
209214}
210215
211- SKIP: {
212- ok( -r $DUMMYINST , ' install dir created' )
213- or skip " $DUMMYINST doesn't exist" , 5;
214- check_dummy_inst($DUMMYINST );
215- }
216+ check_dummy_inst($DUMMYINST , ' ' , ' Module::Install style' );
216217
217218SKIP: {
218219 skip ' VMS install targets do not preserve $(PREFIX)' , 8 if $Is_VMS ;
219-
220- $install_out = run(" $make install PREFIX=elsewhere" );
221- is( $? , 0, ' install with PREFIX override' ) || diag $install_out ;
222- like( $install_out , qr / ^Installing / m );
223-
224- ok( -r ' elsewhere' , ' install dir created' );
225- check_dummy_inst(' elsewhere' );
220+ check_dummy_inst(' elsewhere' , " PREFIX=elsewhere" , ' with PREFIX' );
226221 rmtree(' elsewhere' );
227222}
228223
229-
230224SKIP: {
231225 skip ' VMS install targets do not preserve $(DESTDIR)' , 10 if $Is_VMS ;
232-
233- $install_out = run(" $make install PREFIX= DESTDIR=other" );
234- is( $? , 0, ' install with DESTDIR' ) ||
235- diag $install_out ;
236- like( $install_out , qr / ^Installing / m );
237-
238- ok( -d ' other' , ' destdir created' );
239- my $files = check_dummy_inst(' other' );
240-
241- ok( open (PERLLOCAL, $files -> {' perllocal.pod' } ) ) ||
242- diag(" Can't open $files ->{'perllocal.pod'}: $! " );
243- { local $/ ;
244- unlike(<PERLLOCAL>, qr / other/ , ' DESTDIR should not appear in perllocal' );
245- }
246- close PERLLOCAL;
226+ my $files = check_dummy_inst(' other' , ' PREFIX= DESTDIR=other' , ' with DESTDIR' );
227+ eval {
228+ unlike slurp($files -> {' perllocal.pod' }), qr / other/ , ' DESTDIR should not appear in perllocal' ;
229+ };
230+ is $@ , ' ' ;
247231
248232# TODO not available in the min version of Test::Harness we require
249233# ok( open(PACKLIST, $files{'.packlist'} ) ) ||
@@ -257,18 +241,10 @@ SKIP: {
257241 rmtree(' other' );
258242}
259243
260-
261244SKIP: {
262245 skip ' VMS install targets do not preserve $(PREFIX)' , 9 if $Is_VMS ;
263-
264- $install_out = run(" $make install PREFIX=elsewhere DESTDIR=other/" );
265- is( $? , 0, ' install with PREFIX override and DESTDIR' ) ||
266- diag $install_out ;
267- like( $install_out , qr / ^Installing / m );
268-
246+ check_dummy_inst(' other/elsewhere' , ' PREFIX=elsewhere DESTDIR=other/' , ' PREFIX override and DESTDIR' );
269247 ok( !-d ' elsewhere' , ' install dir not created' );
270- ok( -d ' other/elsewhere' , ' destdir created' );
271- check_dummy_inst(' other/elsewhere' );
272248 rmtree(' other' );
273249}
274250
@@ -491,18 +467,15 @@ close $fh;
491467# now do with "Liar" subdir still there
492468rmtree $DUMMYINST ; # so no false positive from before
493469@mpl_out = run(qq{ $perl Makefile.PL "PREFIX=$DUMMYINST "} );
494- $install_out = run(" $make install" );
495- check_dummy_inst($DUMMYINST );
470+ check_dummy_inst($DUMMYINST , ' ' , " with PREFIX=$DUMMYINST " );
496471# now clean, delete "Liar" subdir, do again
497472$realclean_out = run(" $make realclean" );
498473rmtree ' Liar' ;
499474rmtree $DUMMYINST ; # so no false positive from before
500475@mpl_out = run(qq{ $perl Makefile.PL "PREFIX=$DUMMYINST "} );
501- $install_out = run(" $make install" );
502- check_dummy_inst($DUMMYINST , 1);
476+ check_dummy_inst($DUMMYINST , ' ' , " with PREFIX=$DUMMYINST minus subdir" , 1);
503477
504478sub _normalize {
505479 my $hash = shift ;
506-
507480 %$hash = map { lc ($_ ) => $hash -> {$_ } } keys %$hash ;
508481}
0 commit comments