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 => 73;
20 use MakeMaker::Test::Utils;
25 # 'make disttest' sets a bunch of environment variables which interfere
27 delete @ENV{qw(PREFIX LIB MAKEFLAGS)};
29 my $perl = which_perl();
30 my $Is_VMS = $^O eq 'VMS';
32 chdir($Is_VMS ? 'BFD_TEST_ROOT:[t]' : 't');
37 my $Touch_Time = calibrate_mtime();
41 ok( chdir('Big-Dummy'), "chdir'd to Big-Dummy" ) ||
42 diag("chdir failed: $!");
44 my @mpl_out = run(qq{$perl Makefile.PL "PREFIX=../dummy-install"});
46 cmp_ok( $?, '==', 0, 'Makefile.PL exited with zero' ) ||
49 my $makefile = makefile_name();
50 ok( grep(/^Writing $makefile for Big::Dummy/,
52 'Makefile.PL output looks right');
54 ok( grep(/^Current package is: main$/,
56 'Makefile.PL run in package main');
58 ok( -e $makefile, 'Makefile exists' );
61 my $mtime = (stat($makefile))[9];
62 cmp_ok( $Touch_Time, '<=', $mtime, ' its been touched' );
64 END { unlink makefile_name(), makefile_backup() }
66 my $make = make_run();
69 # Supress 'make manifest' noise
70 local $ENV{PERL_MM_MANIFEST_VERBOSE} = 0;
71 my $manifest_out = run("$make manifest");
72 ok( -e 'MANIFEST', 'make manifest created a MANIFEST' );
73 ok( -s 'MANIFEST', ' its not empty' );
76 END { unlink 'MANIFEST'; }
79 my $ppd_out = run("$make ppd");
80 is( $?, 0, ' exited normally' ) || diag $ppd_out;
81 ok( open(PPD, 'Big-Dummy.ppd'), ' .ppd file generated' );
83 { local $/; $ppd_html = <PPD> }
85 like( $ppd_html, qr{^<SOFTPKG NAME="Big-Dummy" VERSION="0,01,0,0">}m,
87 like( $ppd_html, qr{^\s*<TITLE>Big-Dummy</TITLE>}m, ' <TITLE>' );
88 like( $ppd_html, qr{^\s*<ABSTRACT>Try "our" hot dog's</ABSTRACT>}m,
91 qr{^\s*<AUTHOR>Michael G Schwern <schwern\@pobox.com></AUTHOR>}m,
93 like( $ppd_html, qr{^\s*<IMPLEMENTATION>}m, ' <IMPLEMENTATION>');
94 like( $ppd_html, qr{^\s*<DEPENDENCY NAME="strict" VERSION="0,0,0,0" />}m,
96 like( $ppd_html, qr{^\s*<OS NAME="$Config{osname}" />}m,
98 like( $ppd_html, qr{^\s*<ARCHITECTURE NAME="$Config{archname}" />}m,
100 like( $ppd_html, qr{^\s*<CODEBASE HREF="" />}m, ' <CODEBASE>');
101 like( $ppd_html, qr{^\s*</IMPLEMENTATION>}m, ' </IMPLEMENTATION>');
102 like( $ppd_html, qr{^\s*</SOFTPKG>}m, ' </SOFTPKG>');
103 END { unlink 'Big-Dummy.ppd' }
106 my $test_out = run("$make test");
107 like( $test_out, qr/All tests successful/, 'make test' );
108 is( $?, 0, ' exited normally' );
110 # Test 'make test TEST_VERBOSE=1'
111 my $make_test_verbose = make_macro($make, 'test', TEST_VERBOSE => 1);
112 $test_out = run("$make_test_verbose");
113 like( $test_out, qr/ok \d+ - TEST_VERBOSE/, 'TEST_VERBOSE' );
114 like( $test_out, qr/All tests successful/, ' successful' );
115 is( $?, 0, ' exited normally' );
118 my $install_out = run("$make install");
119 is( $?, 0, 'install' ) || diag $install_out;
120 like( $install_out, qr/^Installing /m );
121 like( $install_out, qr/^Writing /m );
123 ok( -r '../dummy-install', ' install dir created' );
126 # do it case-insensitive for non-case preserving OSs
127 $files{lc $_} = $File::Find::name;
128 }, '../dummy-install' );
129 ok( $files{'dummy.pm'}, ' Dummy.pm installed' );
130 ok( $files{'liar.pm'}, ' Liar.pm installed' );
131 ok( $files{'.packlist'}, ' packlist created' );
132 ok( $files{'perllocal.pod'},' perllocal.pod created' );
136 skip "VMS install targets do not preserve $(PREFIX)", 8 if $Is_VMS;
138 $install_out = run("$make install PREFIX=elsewhere");
139 is( $?, 0, 'install with PREFIX override' ) || diag $install_out;
140 like( $install_out, qr/^Installing /m );
141 like( $install_out, qr/^Writing /m );
143 ok( -r 'elsewhere', ' install dir created' );
145 find( sub { $files{$_} = $File::Find::name; }, 'elsewhere' );
146 ok( $files{'Dummy.pm'}, ' Dummy.pm installed' );
147 ok( $files{'Liar.pm'}, ' Liar.pm installed' );
148 ok( $files{'.packlist'}, ' packlist created' );
149 ok( $files{'perllocal.pod'},' perllocal.pod created' );
155 skip "VMS install targets do not preserve $(DESTDIR)", 10 if $Is_VMS;
157 $install_out = run("$make install PREFIX= DESTDIR=other");
158 is( $?, 0, 'install with DESTDIR' ) ||
160 like( $install_out, qr/^Installing /m );
161 like( $install_out, qr/^Writing /m );
163 ok( -d 'other', ' destdir created' );
167 $files{$_} = $File::Find::name;
169 ok( $files{'Dummy.pm'}, ' Dummy.pm installed' );
170 ok( $files{'Liar.pm'}, ' Liar.pm installed' );
171 ok( $files{'.packlist'}, ' packlist created' );
172 ok( $files{'perllocal.pod'},' perllocal.pod created' );
174 ok( open(PERLLOCAL, $files{'perllocal.pod'} ) ) ||
175 diag("Can't open $files{'perllocal.pod'}: $!");
177 unlike(<PERLLOCAL>, qr/other/, 'DESTDIR should not appear in perllocal');
181 # TODO not available in the min version of Test::Harness we require
182 # ok( open(PACKLIST, $files{'.packlist'} ) ) ||
183 # diag("Can't open $files{'.packlist'}: $!");
185 # local $TODO = 'DESTDIR still in .packlist';
186 # unlike(<PACKLIST>, qr/other/, 'DESTDIR should not appear in .packlist');
195 skip "VMS install targets do not preserve $(PREFIX)", 9 if $Is_VMS;
197 $install_out = run("$make install PREFIX=elsewhere DESTDIR=other/");
198 is( $?, 0, 'install with PREFIX override and DESTDIR' ) ||
200 like( $install_out, qr/^Installing /m );
201 like( $install_out, qr/^Writing /m );
203 ok( !-d 'elsewhere', ' install dir not created' );
204 ok( -d 'other/elsewhere', ' destdir created' );
206 find( sub { $files{$_} = $File::Find::name; }, 'other/elsewhere' );
207 ok( $files{'Dummy.pm'}, ' Dummy.pm installed' );
208 ok( $files{'Liar.pm'}, ' Liar.pm installed' );
209 ok( $files{'.packlist'}, ' packlist created' );
210 ok( $files{'perllocal.pod'},' perllocal.pod created' );
215 my $dist_test_out = run("$make disttest");
216 is( $?, 0, 'disttest' ) || diag($dist_test_out);
218 # Test META.yml generation
219 use ExtUtils::Manifest qw(maniread);
220 ok( -f 'META.yml', 'META.yml written' );
221 my $manifest = maniread();
222 # VMS is non-case preserving, so we can't know what the MANIFEST will
224 _normalize($manifest);
225 is( $manifest->{'meta.yml'}, 'Module meta-data (added by MakeMaker)' );
227 # Test NO_META META.yml suppression
229 ok( !-f 'META.yml', 'META.yml deleted' );
230 @mpl_out = run(qq{$perl Makefile.PL "NO_META=1"});
231 cmp_ok( $?, '==', 0, 'Makefile.PL exited with zero' ) || diag(@mpl_out);
232 my $metafile_out = run("$make metafile");
233 is( $?, 0, 'metafile' ) || diag($metafile_out);
234 ok( !-f 'META.yml', 'META.yml generation suppressed by NO_META' );
236 # Test if MANIFEST is read-only.
237 chmod 0444, 'MANIFEST';
238 @mpl_out = run(qq{$perl Makefile.PL});
239 cmp_ok( $?, '==', 0, 'Makefile.PL exited with zero' ) || diag(@mpl_out);
240 $metafile_out = run("$make metafile_addtomanifest");
241 is( $?, 0, q{metafile_addtomanifest didn't die with locked MANIFEST} ) ||
245 # Make sure init_dirscan doesn't go into the distdir
246 @mpl_out = run(qq{$perl Makefile.PL "PREFIX=../dummy-install"});
248 cmp_ok( $?, '==', 0, 'Makefile.PL exited with zero' ) || diag(@mpl_out);
250 ok( grep(/^Writing $makefile for Big::Dummy/, @mpl_out) == 1,
251 'init_dirscan skipped distdir') ||
254 # I know we'll get ignored errors from make here, that's ok.
255 # Send STDERR off to oblivion.
256 open(SAVERR, ">&STDERR") or die $!;
257 open(STDERR, ">".File::Spec->devnull) or die $!;
259 my $realclean_out = run("$make realclean");
260 is( $?, 0, 'realclean' ) || diag($realclean_out);
262 open(STDERR, ">&SAVERR") or die $!;
269 while(my($k,$v) = each %$hash) {