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