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