This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Move ExtUtils::MakeMaker from ext/ to cpan/
[perl5.git] / cpan / ExtUtils-MakeMaker / t / INST.t
1 #!/usr/bin/perl -w
2
3 # Wherein we ensure the INST_* and INSTALL* variables are set correctly
4 # in a default Makefile.PL run
5 #
6 # Essentially, this test is a Makefile.PL.
7
8 BEGIN {
9     unshift @INC, 't/lib';
10 }
11
12 use strict;
13 use Test::More tests => 26;
14 use MakeMaker::Test::Utils;
15 use MakeMaker::Test::Setup::BFD;
16 use ExtUtils::MakeMaker;
17 use File::Spec;
18 use TieOut;
19 use Config;
20
21 chdir 't';
22
23 perl_lib;
24
25 $| = 1;
26
27 my $Makefile = makefile_name;
28 my $Curdir = File::Spec->curdir;
29 my $Updir  = File::Spec->updir;
30
31 ok( setup_recurs(), 'setup' );
32 END {
33     ok( chdir File::Spec->updir );
34     ok( teardown_recurs(), 'teardown' );
35 }
36
37 ok( chdir 'Big-Dummy', "chdir'd to Big-Dummy" ) ||
38   diag("chdir failed: $!");
39
40 my $stdout = tie *STDOUT, 'TieOut' or die;
41 my $mm = WriteMakefile(
42     NAME          => 'Big::Dummy',
43     VERSION_FROM  => 'lib/Big/Dummy.pm',
44     PREREQ_PM     => {},
45     PERL_CORE     => $ENV{PERL_CORE},
46 );
47 like( $stdout->read, qr{
48                         Writing\ $Makefile\ for\ Big::Liar\n
49                         Big::Liar's\ vars\n
50                         INST_LIB\ =\ \S+\n
51                         INST_ARCHLIB\ =\ \S+\n
52                         Writing\ $Makefile\ for\ Big::Dummy\n
53 }x );
54 undef $stdout;
55 untie *STDOUT;
56
57 isa_ok( $mm, 'ExtUtils::MakeMaker' );
58
59 is( $mm->{NAME}, 'Big::Dummy',  'NAME' );
60 is( $mm->{VERSION}, 0.01,            'VERSION' );
61
62 my $config_prefix = $Config{installprefixexp} || $Config{installprefix} ||
63                     $Config{prefixexp}        || $Config{prefix};
64 is( $mm->{PERLPREFIX}, $config_prefix,   'PERLPREFIX' );
65
66 is( !!$mm->{PERL_CORE}, !!$ENV{PERL_CORE}, 'PERL_CORE' );
67
68 my($perl_src, $mm_perl_src);
69 if( $ENV{PERL_CORE} ) {
70     $perl_src = File::Spec->catdir($Updir, $Updir, $Updir, $Updir);
71     $perl_src = File::Spec->canonpath($perl_src);
72     $mm_perl_src = File::Spec->canonpath($mm->{PERL_SRC});
73 }
74 else {
75     $mm_perl_src = $mm->{PERL_SRC};
76 }
77
78 is( $mm_perl_src, $perl_src,     'PERL_SRC' );
79
80
81 # PERM_*
82 is( $mm->{PERM_RW},  644,    'PERM_RW' );
83 is( $mm->{PERM_RWX}, 755,    'PERM_RWX' );
84
85
86 # INST_*
87 is( $mm->{INST_ARCHLIB}, 
88     $mm->{PERL_CORE} ? $mm->{PERL_ARCHLIB}
89                      : File::Spec->catdir($Curdir, 'blib', 'arch'),
90                                      'INST_ARCHLIB');
91 is( $mm->{INST_BIN},     File::Spec->catdir($Curdir, 'blib', 'bin'),
92                                      'INST_BIN' );
93
94 is( keys %{$mm->{CHILDREN}}, 1 );
95 my($child_pack) = keys %{$mm->{CHILDREN}};
96 my $c_mm = $mm->{CHILDREN}{$child_pack};
97 is( $c_mm->{INST_ARCHLIB}, 
98     $c_mm->{PERL_CORE} ? $c_mm->{PERL_ARCHLIB}
99                        : File::Spec->catdir($Updir, 'blib', 'arch'),
100                                      'CHILD INST_ARCHLIB');
101 is( $c_mm->{INST_BIN},     File::Spec->catdir($Updir, 'blib', 'bin'),
102                                      'CHILD INST_BIN' );
103
104
105 my $inst_lib = File::Spec->catdir($Curdir, 'blib', 'lib');
106 is( $mm->{INST_LIB}, 
107     $mm->{PERL_CORE} ? $mm->{PERL_LIB} : $inst_lib,     'INST_LIB' );
108
109
110 # INSTALL*
111 is( $mm->{INSTALLDIRS}, 'site',     'INSTALLDIRS' );
112
113
114
115 # Make sure the INSTALL*MAN*DIR variables work.  We forgot them
116 # at one point.
117 $stdout = tie *STDOUT, 'TieOut' or die;
118 $mm = WriteMakefile(
119     NAME          => 'Big::Dummy',
120     VERSION_FROM  => 'lib/Big/Dummy.pm',
121     PERL_CORE     => $ENV{PERL_CORE},
122     INSTALLMAN1DIR       => 'none',
123     INSTALLSITEMAN3DIR   => 'none',
124     INSTALLVENDORMAN1DIR => 'none',
125     INST_MAN1DIR         => 'none',
126 );
127 like( $stdout->read, qr{
128                         Writing\ $Makefile\ for\ Big::Liar\n
129                         Big::Liar's\ vars\n
130                         INST_LIB\ =\ \S+\n
131                         INST_ARCHLIB\ =\ \S+\n
132                         Writing\ $Makefile\ for\ Big::Dummy\n
133 }x );
134 undef $stdout;
135 untie *STDOUT;
136
137 isa_ok( $mm, 'ExtUtils::MakeMaker' );
138
139 is  ( $mm->{INSTALLMAN1DIR},        'none' );
140 is  ( $mm->{INSTALLSITEMAN3DIR},    'none' );
141 is  ( $mm->{INSTALLVENDORMAN1DIR},  'none' );
142 is  ( $mm->{INST_MAN1DIR},          'none' );