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