1#!/usr/bin/perl -w 2 3# Tests INSTALL_BASE to a directory without AND with a space in the name 4 5BEGIN { 6 unshift @INC, 't/lib'; 7} 8 9use strict; 10use File::Path; 11use Config; 12my @INSTDIRS = ('../dummy-install', '../dummy install'); 13my $CLEANUP = 1; 14$CLEANUP &&= 1; # so always 1 or numerically 0 15 16use MakeMaker::Test::Utils; 17use MakeMaker::Test::Setup::BFD; 18use Config; 19use ExtUtils::MM; 20use Test::More 21 !MM->can_run(make()) && $ENV{PERL_CORE} && $Config{'usecrosscompile'} 22 ? (skip_all => "cross-compiling and make not available") 23 : (); 24plan tests => 4 + $CLEANUP + @INSTDIRS * (15 + $CLEANUP); 25 26my $Is_VMS = $^O eq 'VMS'; 27 28my $perl = which_perl(); 29 30chdir 't'; 31perl_lib; # sets $ENV{PERL5LIB} relative to t/ 32 33use File::Temp qw[tempdir]; 34my $tmpdir = tempdir( DIR => '../t', CLEANUP => $CLEANUP ); 35use Cwd; my $cwd = getcwd; END { chdir $cwd } # so File::Temp can cleanup 36chdir $tmpdir; 37 38my $SPACEDIR = 'space dir'; 39ok( setup_recurs($SPACEDIR), 'setup' ); 40END { 41 ok( chdir File::Spec->updir, 'chdir updir' ); 42 ok( chdir File::Spec->updir, 'chdir updir again' ); 43 ok( teardown_recurs(), 'teardown' ) if $CLEANUP; 44 map { rmtree $_ } @INSTDIRS if $CLEANUP; 45} 46 47ok( chdir(File::Spec->catdir($SPACEDIR, 'Big-Dummy')), "chdir'd to Big-Dummy") || diag("chdir failed; $!"); 48 49for my $instdir (@INSTDIRS) { 50 $instdir = File::Spec->rel2abs($instdir); 51 $instdir = VMS::Filespec::unixpath($instdir) if $Is_VMS; 52 my @mpl_out = run(qq{$perl Makefile.PL "INSTALL_BASE=$instdir"}); 53 54 cmp_ok( $?, '==', 0, 'Makefile.PL exited with zero' ) || 55 diag(@mpl_out); 56 57 my $makefile = makefile_name(); 58 ok( grep(/^Writing $makefile for Big::Dummy/, 59 @mpl_out) == 1, 60 'Makefile.PL output looks right'); 61 62 my $make = make_run(); 63 run("$make"); # this is necessary due to a dmake bug. 64 my $install_out = run("$make install"); 65 is( $?, 0, ' make install exited normally' ) || diag $install_out; 66 like( $install_out, qr/^Installing /m, '"Installing" in output' ); 67 68 ok( -r $instdir, ' install dir created' ); 69 70 my @installed_files = 71 ("$instdir/lib/perl5/Big/Dummy.pm", 72 "$instdir/lib/perl5/Big/Liar.pm", 73 "$instdir/bin/program", 74 "$instdir/lib/perl5/$Config{archname}/perllocal.pod", 75 "$instdir/lib/perl5/$Config{archname}/auto/Big/Dummy/.packlist" 76 ); 77 78 foreach my $file (@installed_files) { 79 ok( -e $file, " $file installed" ); 80 ok( -r $file, " $file readable" ); 81 } 82 83 84 # nmake outputs its damned logo 85 # Send STDERR off to oblivion. 86 open(SAVERR, ">&STDERR") or die $!; 87 open(STDERR, ">".File::Spec->devnull) or die $!; 88 89 if ($CLEANUP) { 90 my $realclean_out = run("$make realclean"); 91 is( $?, 0, 'realclean' ) || diag($realclean_out); 92 } 93 94 open(STDERR, ">&SAVERR") or die $!; 95 close SAVERR; 96} 97