Commit | Line | Data |
75e2e551 |
1 | #!/usr/bin/perl -w |
2 | |
3 | # This test puts MakeMaker through the paces of a basic perl module |
4 | # build, test and installation of the Big::Fat::Dummy module. |
5 | |
6 | BEGIN { |
7 | if( $ENV{PERL_CORE} ) { |
8 | chdir 't' if -d 't'; |
9 | @INC = ('../lib', 'lib'); |
10 | } |
11 | else { |
12 | unshift @INC, 't/lib'; |
13 | } |
14 | } |
15 | |
16 | use strict; |
479d2113 |
17 | use Config; |
18 | |
a7d1454b |
19 | use Test::More tests => 79; |
75e2e551 |
20 | use MakeMaker::Test::Utils; |
a7d1454b |
21 | use MakeMaker::Test::Setup::BFD; |
479d2113 |
22 | use File::Find; |
75e2e551 |
23 | use File::Spec; |
5e719f03 |
24 | use File::Path; |
75e2e551 |
25 | |
dedf98bc |
26 | # 'make disttest' sets a bunch of environment variables which interfere |
27 | # with our testing. |
28 | delete @ENV{qw(PREFIX LIB MAKEFLAGS)}; |
29 | |
e0678a30 |
30 | my $perl = which_perl(); |
479d2113 |
31 | my $Is_VMS = $^O eq 'VMS'; |
75e2e551 |
32 | |
431b0fc4 |
33 | chdir($Is_VMS ? 'BFD_TEST_ROOT:[t]' : 't'); |
57b1a898 |
34 | |
75e2e551 |
35 | |
36 | perl_lib; |
37 | |
e0678a30 |
38 | my $Touch_Time = calibrate_mtime(); |
39 | |
75e2e551 |
40 | $| = 1; |
41 | |
a7d1454b |
42 | ok( setup_recurs(), 'setup' ); |
43 | END { |
44 | ok( chdir File::Spec->updir ); |
45 | ok( teardown_recurs(), 'teardown' ); |
46 | } |
47 | |
5e719f03 |
48 | ok( chdir('Big-Dummy'), "chdir'd to Big-Dummy" ) || |
75e2e551 |
49 | diag("chdir failed: $!"); |
50 | |
1df8d179 |
51 | my @mpl_out = run(qq{$perl Makefile.PL "PREFIX=../dummy-install"}); |
30361541 |
52 | END { rmtree '../dummy-install'; } |
75e2e551 |
53 | |
54 | cmp_ok( $?, '==', 0, 'Makefile.PL exited with zero' ) || |
55 | diag(@mpl_out); |
56 | |
57 | my $makefile = makefile_name(); |
45bc4d3a |
58 | ok( grep(/^Writing $makefile for Big::Dummy/, |
75e2e551 |
59 | @mpl_out) == 1, |
60 | 'Makefile.PL output looks right'); |
61 | |
62 | ok( grep(/^Current package is: main$/, |
63 | @mpl_out) == 1, |
64 | 'Makefile.PL run in package main'); |
65 | |
66 | ok( -e $makefile, 'Makefile exists' ); |
67 | |
e0678a30 |
68 | # -M is flakey on VMS |
69 | my $mtime = (stat($makefile))[9]; |
70 | cmp_ok( $Touch_Time, '<=', $mtime, ' its been touched' ); |
75e2e551 |
71 | |
72 | END { unlink makefile_name(), makefile_backup() } |
73 | |
74 | my $make = make_run(); |
75 | |
76 | { |
77 | # Supress 'make manifest' noise |
78 | local $ENV{PERL_MM_MANIFEST_VERBOSE} = 0; |
dedf98bc |
79 | my $manifest_out = run("$make manifest"); |
75e2e551 |
80 | ok( -e 'MANIFEST', 'make manifest created a MANIFEST' ); |
81 | ok( -s 'MANIFEST', ' its not empty' ); |
82 | } |
83 | |
84 | END { unlink 'MANIFEST'; } |
85 | |
479d2113 |
86 | |
dedf98bc |
87 | my $ppd_out = run("$make ppd"); |
88 | is( $?, 0, ' exited normally' ) || diag $ppd_out; |
479d2113 |
89 | ok( open(PPD, 'Big-Dummy.ppd'), ' .ppd file generated' ); |
90 | my $ppd_html; |
91 | { local $/; $ppd_html = <PPD> } |
92 | close PPD; |
93 | like( $ppd_html, qr{^<SOFTPKG NAME="Big-Dummy" VERSION="0,01,0,0">}m, |
94 | ' <SOFTPKG>' ); |
95 | like( $ppd_html, qr{^\s*<TITLE>Big-Dummy</TITLE>}m, ' <TITLE>' ); |
96 | like( $ppd_html, qr{^\s*<ABSTRACT>Try "our" hot dog's</ABSTRACT>}m, |
97 | ' <ABSTRACT>'); |
98 | like( $ppd_html, |
99 | qr{^\s*<AUTHOR>Michael G Schwern <schwern\@pobox.com></AUTHOR>}m, |
100 | ' <AUTHOR>' ); |
101 | like( $ppd_html, qr{^\s*<IMPLEMENTATION>}m, ' <IMPLEMENTATION>'); |
102 | like( $ppd_html, qr{^\s*<DEPENDENCY NAME="strict" VERSION="0,0,0,0" />}m, |
103 | ' <DEPENDENCY>' ); |
104 | like( $ppd_html, qr{^\s*<OS NAME="$Config{osname}" />}m, |
105 | ' <OS>' ); |
106 | like( $ppd_html, qr{^\s*<ARCHITECTURE NAME="$Config{archname}" />}m, |
107 | ' <ARCHITECTURE>'); |
108 | like( $ppd_html, qr{^\s*<CODEBASE HREF="" />}m, ' <CODEBASE>'); |
109 | like( $ppd_html, qr{^\s*</IMPLEMENTATION>}m, ' </IMPLEMENTATION>'); |
110 | like( $ppd_html, qr{^\s*</SOFTPKG>}m, ' </SOFTPKG>'); |
111 | END { unlink 'Big-Dummy.ppd' } |
112 | |
113 | |
dedf98bc |
114 | my $test_out = run("$make test"); |
75e2e551 |
115 | like( $test_out, qr/All tests successful/, 'make test' ); |
0fdc96ff |
116 | is( $?, 0, ' exited normally' ) || |
117 | diag $test_out; |
75e2e551 |
118 | |
119 | # Test 'make test TEST_VERBOSE=1' |
120 | my $make_test_verbose = make_macro($make, 'test', TEST_VERBOSE => 1); |
dedf98bc |
121 | $test_out = run("$make_test_verbose"); |
75e2e551 |
122 | like( $test_out, qr/ok \d+ - TEST_VERBOSE/, 'TEST_VERBOSE' ); |
479d2113 |
123 | like( $test_out, qr/All tests successful/, ' successful' ); |
0fdc96ff |
124 | is( $?, 0, ' exited normally' ) || |
125 | diag $test_out; |
479d2113 |
126 | |
127 | |
dedf98bc |
128 | my $install_out = run("$make install"); |
479d2113 |
129 | is( $?, 0, 'install' ) || diag $install_out; |
130 | like( $install_out, qr/^Installing /m ); |
131 | like( $install_out, qr/^Writing /m ); |
132 | |
1df8d179 |
133 | ok( -r '../dummy-install', ' install dir created' ); |
479d2113 |
134 | my %files = (); |
135 | find( sub { |
136 | # do it case-insensitive for non-case preserving OSs |
137 | $files{lc $_} = $File::Find::name; |
1df8d179 |
138 | }, '../dummy-install' ); |
479d2113 |
139 | ok( $files{'dummy.pm'}, ' Dummy.pm installed' ); |
140 | ok( $files{'liar.pm'}, ' Liar.pm installed' ); |
141 | ok( $files{'.packlist'}, ' packlist created' ); |
142 | ok( $files{'perllocal.pod'},' perllocal.pod created' ); |
143 | |
144 | |
145 | SKIP: { |
5e719f03 |
146 | skip "VMS install targets do not preserve $(PREFIX)", 8 if $Is_VMS; |
479d2113 |
147 | |
dedf98bc |
148 | $install_out = run("$make install PREFIX=elsewhere"); |
479d2113 |
149 | is( $?, 0, 'install with PREFIX override' ) || diag $install_out; |
150 | like( $install_out, qr/^Installing /m ); |
151 | like( $install_out, qr/^Writing /m ); |
152 | |
153 | ok( -r 'elsewhere', ' install dir created' ); |
154 | %files = (); |
155 | find( sub { $files{$_} = $File::Find::name; }, 'elsewhere' ); |
156 | ok( $files{'Dummy.pm'}, ' Dummy.pm installed' ); |
157 | ok( $files{'Liar.pm'}, ' Liar.pm installed' ); |
158 | ok( $files{'.packlist'}, ' packlist created' ); |
159 | ok( $files{'perllocal.pod'},' perllocal.pod created' ); |
5e719f03 |
160 | rmtree('elsewhere'); |
161 | } |
162 | |
163 | |
164 | SKIP: { |
165 | skip "VMS install targets do not preserve $(DESTDIR)", 10 if $Is_VMS; |
166 | |
167 | $install_out = run("$make install PREFIX= DESTDIR=other"); |
168 | is( $?, 0, 'install with DESTDIR' ) || |
169 | diag $install_out; |
170 | like( $install_out, qr/^Installing /m ); |
171 | like( $install_out, qr/^Writing /m ); |
172 | |
173 | ok( -d 'other', ' destdir created' ); |
174 | %files = (); |
175 | my $perllocal; |
176 | find( sub { |
177 | $files{$_} = $File::Find::name; |
178 | }, 'other' ); |
179 | ok( $files{'Dummy.pm'}, ' Dummy.pm installed' ); |
180 | ok( $files{'Liar.pm'}, ' Liar.pm installed' ); |
181 | ok( $files{'.packlist'}, ' packlist created' ); |
182 | ok( $files{'perllocal.pod'},' perllocal.pod created' ); |
183 | |
184 | ok( open(PERLLOCAL, $files{'perllocal.pod'} ) ) || |
185 | diag("Can't open $files{'perllocal.pod'}: $!"); |
186 | { local $/; |
187 | unlike(<PERLLOCAL>, qr/other/, 'DESTDIR should not appear in perllocal'); |
188 | } |
189 | close PERLLOCAL; |
190 | |
191 | # TODO not available in the min version of Test::Harness we require |
192 | # ok( open(PACKLIST, $files{'.packlist'} ) ) || |
193 | # diag("Can't open $files{'.packlist'}: $!"); |
194 | # { local $/; |
195 | # local $TODO = 'DESTDIR still in .packlist'; |
196 | # unlike(<PACKLIST>, qr/other/, 'DESTDIR should not appear in .packlist'); |
197 | # } |
198 | # close PACKLIST; |
199 | |
200 | rmtree('other'); |
201 | } |
202 | |
203 | |
204 | SKIP: { |
205 | skip "VMS install targets do not preserve $(PREFIX)", 9 if $Is_VMS; |
206 | |
207 | $install_out = run("$make install PREFIX=elsewhere DESTDIR=other/"); |
208 | is( $?, 0, 'install with PREFIX override and DESTDIR' ) || |
209 | diag $install_out; |
210 | like( $install_out, qr/^Installing /m ); |
211 | like( $install_out, qr/^Writing /m ); |
212 | |
213 | ok( !-d 'elsewhere', ' install dir not created' ); |
214 | ok( -d 'other/elsewhere', ' destdir created' ); |
215 | %files = (); |
216 | find( sub { $files{$_} = $File::Find::name; }, 'other/elsewhere' ); |
217 | ok( $files{'Dummy.pm'}, ' Dummy.pm installed' ); |
218 | ok( $files{'Liar.pm'}, ' Liar.pm installed' ); |
219 | ok( $files{'.packlist'}, ' packlist created' ); |
220 | ok( $files{'perllocal.pod'},' perllocal.pod created' ); |
221 | rmtree('other'); |
479d2113 |
222 | } |
223 | |
75e2e551 |
224 | |
dedf98bc |
225 | my $dist_test_out = run("$make disttest"); |
75e2e551 |
226 | is( $?, 0, 'disttest' ) || diag($dist_test_out); |
227 | |
479d2113 |
228 | # Test META.yml generation |
229 | use ExtUtils::Manifest qw(maniread); |
230 | ok( -f 'META.yml', 'META.yml written' ); |
231 | my $manifest = maniread(); |
232 | # VMS is non-case preserving, so we can't know what the MANIFEST will |
233 | # look like. :( |
234 | _normalize($manifest); |
2530b651 |
235 | is( $manifest->{'meta.yml'}, 'Module meta-data (added by MakeMaker)' ); |
a7d1454b |
236 | my $meta_mtime = (stat('META.yml'))[9]; |
237 | |
238 | sleep 1; |
239 | my $metafile_out = run("$make metafile"); |
240 | is( $?, 0, 'metafile' ) || diag($metafile_out); |
241 | is( (stat('META.yml'))[9], $meta_mtime, 'META.yml untouched if not changed' ); |
242 | ok( !-e 'META_new.yml', 'temp META.yml file not left around' ); |
479d2113 |
243 | |
431b0fc4 |
244 | # Test NO_META META.yml suppression |
245 | unlink 'META.yml'; |
246 | ok( !-f 'META.yml', 'META.yml deleted' ); |
247 | @mpl_out = run(qq{$perl Makefile.PL "NO_META=1"}); |
248 | cmp_ok( $?, '==', 0, 'Makefile.PL exited with zero' ) || diag(@mpl_out); |
a7d1454b |
249 | $metafile_out = run("$make metafile"); |
431b0fc4 |
250 | is( $?, 0, 'metafile' ) || diag($metafile_out); |
251 | ok( !-f 'META.yml', 'META.yml generation suppressed by NO_META' ); |
252 | |
1df8d179 |
253 | # Test if MANIFEST is read-only. |
254 | chmod 0444, 'MANIFEST'; |
255 | @mpl_out = run(qq{$perl Makefile.PL}); |
256 | cmp_ok( $?, '==', 0, 'Makefile.PL exited with zero' ) || diag(@mpl_out); |
257 | $metafile_out = run("$make metafile_addtomanifest"); |
258 | is( $?, 0, q{metafile_addtomanifest didn't die with locked MANIFEST} ) || |
259 | diag($metafile_out); |
260 | |
e0678a30 |
261 | |
262 | # Make sure init_dirscan doesn't go into the distdir |
1df8d179 |
263 | @mpl_out = run(qq{$perl Makefile.PL "PREFIX=../dummy-install"}); |
e0678a30 |
264 | |
431b0fc4 |
265 | cmp_ok( $?, '==', 0, 'Makefile.PL exited with zero' ) || diag(@mpl_out); |
e0678a30 |
266 | |
479d2113 |
267 | ok( grep(/^Writing $makefile for Big::Dummy/, @mpl_out) == 1, |
e0678a30 |
268 | 'init_dirscan skipped distdir') || |
269 | diag(@mpl_out); |
270 | |
271 | # I know we'll get ignored errors from make here, that's ok. |
272 | # Send STDERR off to oblivion. |
273 | open(SAVERR, ">&STDERR") or die $!; |
274 | open(STDERR, ">".File::Spec->devnull) or die $!; |
275 | |
dedf98bc |
276 | my $realclean_out = run("$make realclean"); |
75e2e551 |
277 | is( $?, 0, 'realclean' ) || diag($realclean_out); |
278 | |
e0678a30 |
279 | open(STDERR, ">&SAVERR") or die $!; |
280 | close SAVERR; |
479d2113 |
281 | |
282 | |
283 | sub _normalize { |
284 | my $hash = shift; |
285 | |
286 | while(my($k,$v) = each %$hash) { |
287 | delete $hash->{$k}; |
288 | $hash->{lc $k} = $v; |
289 | } |
290 | } |