3 # This test puts MakeMaker through the paces of a basic perl module
4 # build, test and installation of the Big::Fat::Dummy module.
7 if( $ENV{PERL_CORE} ) {
9 @INC = ('../lib', 'lib');
12 unshift @INC, 't/lib';
19 use Test::More tests => 79;
20 use MakeMaker::Test::Utils;
21 use MakeMaker::Test::Setup::BFD;
26 # 'make disttest' sets a bunch of environment variables which interfere
28 delete @ENV{qw(PREFIX LIB MAKEFLAGS)};
30 my $perl = which_perl();
31 my $Is_VMS = $^O eq 'VMS';
33 chdir($Is_VMS ? 'BFD_TEST_ROOT:[t]' : 't');
38 my $Touch_Time = calibrate_mtime();
42 ok( setup_recurs(), 'setup' );
44 ok( chdir File::Spec->updir );
45 ok( teardown_recurs(), 'teardown' );
48 ok( chdir('Big-Dummy'), "chdir'd to Big-Dummy" ) ||
49 diag("chdir failed: $!");
51 my @mpl_out = run(qq{$perl Makefile.PL "PREFIX=../dummy-install"});
52 END { rmtree '../dummy-install'; }
54 cmp_ok( $?, '==', 0, 'Makefile.PL exited with zero' ) ||
57 my $makefile = makefile_name();
58 ok( grep(/^Writing $makefile for Big::Dummy/,
60 'Makefile.PL output looks right');
62 ok( grep(/^Current package is: main$/,
64 'Makefile.PL run in package main');
66 ok( -e $makefile, 'Makefile exists' );
69 my $mtime = (stat($makefile))[9];
70 cmp_ok( $Touch_Time, '<=', $mtime, ' its been touched' );
72 END { unlink makefile_name(), makefile_backup() }
74 my $make = make_run();
77 # Supress 'make manifest' noise
78 local $ENV{PERL_MM_MANIFEST_VERBOSE} = 0;
79 my $manifest_out = run("$make manifest");
80 ok( -e 'MANIFEST', 'make manifest created a MANIFEST' );
81 ok( -s 'MANIFEST', ' its not empty' );
84 END { unlink 'MANIFEST'; }
87 my $ppd_out = run("$make ppd");
88 is( $?, 0, ' exited normally' ) || diag $ppd_out;
89 ok( open(PPD, 'Big-Dummy.ppd'), ' .ppd file generated' );
91 { local $/; $ppd_html = <PPD> }
93 like( $ppd_html, qr{^<SOFTPKG NAME="Big-Dummy" VERSION="0,01,0,0">}m,
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,
99 qr{^\s*<AUTHOR>Michael G Schwern <schwern\@pobox.com></AUTHOR>}m,
101 like( $ppd_html, qr{^\s*<IMPLEMENTATION>}m, ' <IMPLEMENTATION>');
102 like( $ppd_html, qr{^\s*<DEPENDENCY NAME="strict" VERSION="0,0,0,0" />}m,
104 like( $ppd_html, qr{^\s*<OS NAME="$Config{osname}" />}m,
106 like( $ppd_html, qr{^\s*<ARCHITECTURE NAME="$Config{archname}" />}m,
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' }
114 my $test_out = run("$make test");
115 like( $test_out, qr/All tests successful/, 'make test' );
116 is( $?, 0, ' exited normally' ) ||
119 # Test 'make test TEST_VERBOSE=1'
120 my $make_test_verbose = make_macro($make, 'test', TEST_VERBOSE => 1);
121 $test_out = run("$make_test_verbose");
122 like( $test_out, qr/ok \d+ - TEST_VERBOSE/, 'TEST_VERBOSE' );
123 like( $test_out, qr/All tests successful/, ' successful' );
124 is( $?, 0, ' exited normally' ) ||
128 my $install_out = run("$make install");
129 is( $?, 0, 'install' ) || diag $install_out;
130 like( $install_out, qr/^Installing /m );
131 like( $install_out, qr/^Writing /m );
133 ok( -r '../dummy-install', ' install dir created' );
136 # do it case-insensitive for non-case preserving OSs
137 $files{lc $_} = $File::Find::name;
138 }, '../dummy-install' );
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' );
146 skip "VMS install targets do not preserve $(PREFIX)", 8 if $Is_VMS;
148 $install_out = run("$make install PREFIX=elsewhere");
149 is( $?, 0, 'install with PREFIX override' ) || diag $install_out;
150 like( $install_out, qr/^Installing /m );
151 like( $install_out, qr/^Writing /m );
153 ok( -r 'elsewhere', ' install dir created' );
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' );
165 skip "VMS install targets do not preserve $(DESTDIR)", 10 if $Is_VMS;
167 $install_out = run("$make install PREFIX= DESTDIR=other");
168 is( $?, 0, 'install with DESTDIR' ) ||
170 like( $install_out, qr/^Installing /m );
171 like( $install_out, qr/^Writing /m );
173 ok( -d 'other', ' destdir created' );
177 $files{$_} = $File::Find::name;
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' );
184 ok( open(PERLLOCAL, $files{'perllocal.pod'} ) ) ||
185 diag("Can't open $files{'perllocal.pod'}: $!");
187 unlike(<PERLLOCAL>, qr/other/, 'DESTDIR should not appear in perllocal');
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'}: $!");
195 # local $TODO = 'DESTDIR still in .packlist';
196 # unlike(<PACKLIST>, qr/other/, 'DESTDIR should not appear in .packlist');
205 skip "VMS install targets do not preserve $(PREFIX)", 9 if $Is_VMS;
207 $install_out = run("$make install PREFIX=elsewhere DESTDIR=other/");
208 is( $?, 0, 'install with PREFIX override and DESTDIR' ) ||
210 like( $install_out, qr/^Installing /m );
211 like( $install_out, qr/^Writing /m );
213 ok( !-d 'elsewhere', ' install dir not created' );
214 ok( -d 'other/elsewhere', ' destdir created' );
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' );
225 my $dist_test_out = run("$make disttest");
226 is( $?, 0, 'disttest' ) || diag($dist_test_out);
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
234 _normalize($manifest);
235 is( $manifest->{'meta.yml'}, 'Module meta-data (added by MakeMaker)' );
236 my $meta_mtime = (stat('META.yml'))[9];
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' );
244 # Test NO_META META.yml suppression
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);
249 $metafile_out = run("$make metafile");
250 is( $?, 0, 'metafile' ) || diag($metafile_out);
251 ok( !-f 'META.yml', 'META.yml generation suppressed by NO_META' );
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} ) ||
262 # Make sure init_dirscan doesn't go into the distdir
263 @mpl_out = run(qq{$perl Makefile.PL "PREFIX=../dummy-install"});
265 cmp_ok( $?, '==', 0, 'Makefile.PL exited with zero' ) || diag(@mpl_out);
267 ok( grep(/^Writing $makefile for Big::Dummy/, @mpl_out) == 1,
268 'init_dirscan skipped distdir') ||
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 $!;
276 my $realclean_out = run("$make realclean");
277 is( $?, 0, 'realclean' ) || diag($realclean_out);
279 open(STDERR, ">&SAVERR") or die $!;
286 while(my($k,$v) = each %$hash) {