Commit | Line | Data |
5c161494 |
1 | #!/usr/bin/perl -w |
2 | |
3 | # Wherein we ensure the INST_* and INSTALL* variables are set correctly |
4 | # when various PREFIX variables are set. |
5 | # |
6 | # Essentially, this test is a Makefile.PL. |
7 | |
8 | BEGIN { |
9 | if( $ENV{PERL_CORE} ) { |
10 | chdir 't' if -d 't'; |
11 | @INC = ('../lib', 'lib'); |
12 | } |
13 | else { |
14 | unshift @INC, 't/lib'; |
15 | } |
16 | } |
17 | |
18 | use strict; |
5e719f03 |
19 | use Test::More tests => 36; |
5c161494 |
20 | use MakeMaker::Test::Utils; |
21 | use ExtUtils::MakeMaker; |
22 | use File::Spec; |
23 | use TieOut; |
24 | use Config; |
25 | |
45bc4d3a |
26 | my $Is_VMS = $^O eq 'VMS'; |
27 | |
28 | chdir 't'; |
5c161494 |
29 | |
30 | perl_lib; |
31 | |
32 | $| = 1; |
33 | |
34 | my $Makefile = makefile_name; |
35 | my $Curdir = File::Spec->curdir; |
36 | my $Updir = File::Spec->updir; |
37 | |
45bc4d3a |
38 | ok( chdir 'Big-Dummy', "chdir'd to Big-Dummy" ) || |
5c161494 |
39 | diag("chdir failed: $!"); |
40 | |
41 | my $stdout = tie *STDOUT, 'TieOut' or die; |
479d2113 |
42 | |
5c161494 |
43 | my $mm = WriteMakefile( |
45bc4d3a |
44 | NAME => 'Big::Dummy', |
45 | VERSION_FROM => 'lib/Big/Dummy.pm', |
5c161494 |
46 | PREREQ_PM => {}, |
47 | PERL_CORE => $ENV{PERL_CORE}, |
5c161494 |
48 | ); |
479d2113 |
49 | |
5c161494 |
50 | like( $stdout->read, qr{ |
45bc4d3a |
51 | Writing\ $Makefile\ for\ Big::Liar\n |
52 | Big::Liar's\ vars\n |
5c161494 |
53 | INST_LIB\ =\ \S+\n |
54 | INST_ARCHLIB\ =\ \S+\n |
45bc4d3a |
55 | Writing\ $Makefile\ for\ Big::Dummy\n |
5c161494 |
56 | }x ); |
5c161494 |
57 | |
58 | isa_ok( $mm, 'ExtUtils::MakeMaker' ); |
59 | |
45bc4d3a |
60 | is( $mm->{NAME}, 'Big::Dummy', 'NAME' ); |
5c161494 |
61 | is( $mm->{VERSION}, 0.01, 'VERSION' ); |
62 | |
479d2113 |
63 | foreach my $prefix (qw(PREFIX PERLPREFIX SITEPREFIX VENDORPREFIX)) { |
64 | unlike( $mm->{$prefix}, qr/\$\(PREFIX\)/ ); |
479d2113 |
65 | } |
66 | |
67 | |
68 | my $PREFIX = File::Spec->catdir('foo', 'bar'); |
69 | $mm = WriteMakefile( |
70 | NAME => 'Big::Dummy', |
71 | VERSION_FROM => 'lib/Big/Dummy.pm', |
72 | PREREQ_PM => {}, |
73 | PERL_CORE => $ENV{PERL_CORE}, |
74 | PREFIX => $PREFIX, |
75 | ); |
76 | like( $stdout->read, qr{ |
77 | Writing\ $Makefile\ for\ Big::Liar\n |
78 | Big::Liar's\ vars\n |
79 | INST_LIB\ =\ \S+\n |
80 | INST_ARCHLIB\ =\ \S+\n |
81 | Writing\ $Makefile\ for\ Big::Dummy\n |
82 | }x ); |
83 | undef $stdout; |
84 | untie *STDOUT; |
85 | |
5e719f03 |
86 | is( $mm->{PREFIX}, $PREFIX, 'PREFIX' ); |
479d2113 |
87 | |
88 | foreach my $prefix (qw(PERLPREFIX SITEPREFIX VENDORPREFIX)) { |
5e719f03 |
89 | is( $mm->{$prefix}, '$(PREFIX)', "\$(PREFIX) overrides $prefix" ); |
479d2113 |
90 | } |
5c161494 |
91 | |
92 | is( !!$mm->{PERL_CORE}, !!$ENV{PERL_CORE}, 'PERL_CORE' ); |
93 | |
94 | my($perl_src, $mm_perl_src); |
95 | if( $ENV{PERL_CORE} ) { |
45bc4d3a |
96 | $perl_src = File::Spec->catdir($Updir, $Updir); |
5c161494 |
97 | $perl_src = File::Spec->canonpath($perl_src); |
98 | $mm_perl_src = File::Spec->canonpath($mm->{PERL_SRC}); |
99 | } |
100 | else { |
101 | $mm_perl_src = $mm->{PERL_SRC}; |
102 | } |
103 | |
104 | is( $mm_perl_src, $perl_src, 'PERL_SRC' ); |
105 | |
106 | |
107 | # Every INSTALL* variable must start with some PREFIX. |
479d2113 |
108 | my %Install_Vars = ( |
109 | PERL => [qw(archlib privlib bin man1dir man3dir script)], |
110 | SITE => [qw(sitearch sitelib sitebin siteman1dir siteman3dir)], |
111 | VENDOR => [qw(vendorarch vendorlib vendorbin vendorman1dir vendorman3dir)] |
112 | ); |
5c161494 |
113 | |
479d2113 |
114 | while( my($type, $vars) = each %Install_Vars) { |
45bc4d3a |
115 | |
479d2113 |
116 | SKIP: foreach my $var (@$vars) { |
117 | skip "VMS must expand macros in INSTALL* vars", scalar @$vars |
118 | if $Is_VMS; |
5c161494 |
119 | |
479d2113 |
120 | my $prefix = '$('.$type.'PREFIX)'; |
45bc4d3a |
121 | |
479d2113 |
122 | # support for man page skipping |
123 | $prefix = 'none' if $type eq 'PERL' && |
124 | $var =~ /man/ && |
125 | !$Config{"install$var"}; |
126 | like( $mm->{uc "install$var"}, qr/^\Q$prefix\E/, "$prefix + $var" ); |
127 | } |
5c161494 |
128 | } |
45bc4d3a |
129 | |
45bc4d3a |
130 | # Check that when installman*dir isn't set in Config no man pages |
131 | # are generated. |
132 | { |
133 | undef *ExtUtils::MM_Unix::Config; |
5e719f03 |
134 | undef *ExtUtils::MM_Unix::Config_Override; |
45bc4d3a |
135 | %ExtUtils::MM_Unix::Config = %Config; |
5e719f03 |
136 | *ExtUtils::MM_VMS::Config = \%ExtUtils::MM_Unix::Config; |
137 | |
45bc4d3a |
138 | $ExtUtils::MM_Unix::Config{installman1dir} = ''; |
139 | $ExtUtils::MM_Unix::Config{installman3dir} = ''; |
140 | |
141 | my $wibble = File::Spec->catdir(qw(wibble and such)); |
142 | my $stdout = tie *STDOUT, 'TieOut' or die; |
143 | my $mm = WriteMakefile( |
144 | NAME => 'Big::Dummy', |
145 | VERSION_FROM => 'lib/Big/Dummy.pm', |
146 | PREREQ_PM => {}, |
147 | PERL_CORE => $ENV{PERL_CORE}, |
148 | PREFIX => $PREFIX, |
149 | INSTALLMAN1DIR=> $wibble, |
150 | ); |
151 | |
152 | is( $mm->{INSTALLMAN1DIR}, $wibble ); |
153 | is( $mm->{INSTALLMAN3DIR}, 'none' ); |
154 | } |
5e719f03 |
155 | |
156 | # Check that when installvendorman*dir is set in Config it is honored |
157 | # [rt.cpan.org 2949] |
158 | { |
159 | undef *ExtUtils::MM_Unix::Config; |
160 | undef *ExtUtils::MM_Unix::Config_Override; |
161 | undef *ExtUtils::MM_VMS::Config; |
162 | |
163 | %ExtUtils::MM_Unix::Config = %Config; |
164 | *ExtUtils::MM_VMS::Config = \%ExtUtils::MM_Unix::Config; |
165 | |
166 | $ExtUtils::MM_Unix::Config{installvendorman1dir} = |
167 | File::Spec->catdir('foo','bar'); |
168 | $ExtUtils::MM_Unix::Config{installvendorman3dir} = ''; |
169 | $ExtUtils::MM_Unix::Config{usevendorprefix} = 1; |
170 | $ExtUtils::MM_Unix::Config{vendorprefixexp} = 'something'; |
171 | |
172 | my $stdout = tie *STDOUT, 'TieOut' or die; |
173 | my $mm = WriteMakefile( |
174 | NAME => 'Big::Dummy', |
175 | VERSION_FROM => 'lib/Big/Dummy.pm', |
176 | PREREQ_PM => {}, |
177 | PERL_CORE => $ENV{PERL_CORE}, |
178 | |
179 | # In case the local installation doesn't have man pages. |
180 | INSTALLMAN1DIR=> 'foo/bar/baz', |
181 | INSTALLMAN3DIR=> 'foo/bar/baz', |
182 | ); |
183 | |
184 | is( $mm->{INSTALLVENDORMAN1DIR}, File::Spec->catdir('foo','bar'), |
185 | 'installvendorman1dir (in %Config) not modified' ); |
186 | isnt( $mm->{INSTALLVENDORMAN3DIR}, '', |
187 | 'installvendorman3dir (not in %Config) set' ); |
188 | } |