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"});
45 END { rmtree '../dummy-install'; }
47 cmp_ok( $?, '==', 0, 'Makefile.PL exited with zero' ) ||
50 my $makefile = makefile_name();
51 ok( grep(/^Writing $makefile for Big::Dummy/,
53 'Makefile.PL output looks right');
55 ok( grep(/^Current package is: main$/,
57 'Makefile.PL run in package main');
59 ok( -e $makefile, 'Makefile exists' );
62 my $mtime = (stat($makefile))[9];
63 cmp_ok( $Touch_Time, '<=', $mtime, ' its been touched' );
65 END { unlink makefile_name(), makefile_backup() }
67 my $make = make_run();
70 # Supress 'make manifest' noise
71 local $ENV{PERL_MM_MANIFEST_VERBOSE} = 0;
72 my $manifest_out = run("$make manifest");
73 ok( -e 'MANIFEST', 'make manifest created a MANIFEST' );
74 ok( -s 'MANIFEST', ' its not empty' );
77 END { unlink 'MANIFEST'; }
80 my $ppd_out = run("$make ppd");
81 is( $?, 0, ' exited normally' ) || diag $ppd_out;
82 ok( open(PPD, 'Big-Dummy.ppd'), ' .ppd file generated' );
84 { local $/; $ppd_html = <PPD> }
86 like( $ppd_html, qr{^<SOFTPKG NAME="Big-Dummy" VERSION="0,01,0,0">}m,
88 like( $ppd_html, qr{^\s*<TITLE>Big-Dummy</TITLE>}m, ' <TITLE>' );
89 like( $ppd_html, qr{^\s*<ABSTRACT>Try "our" hot dog's</ABSTRACT>}m,
92 qr{^\s*<AUTHOR>Michael G Schwern <schwern\@pobox.com></AUTHOR>}m,
94 like( $ppd_html, qr{^\s*<IMPLEMENTATION>}m, ' <IMPLEMENTATION>');
95 like( $ppd_html, qr{^\s*<DEPENDENCY NAME="strict" VERSION="0,0,0,0" />}m,
97 like( $ppd_html, qr{^\s*<OS NAME="$Config{osname}" />}m,
99 like( $ppd_html, qr{^\s*<ARCHITECTURE NAME="$Config{archname}" />}m,
101 like( $ppd_html, qr{^\s*<CODEBASE HREF="" />}m, ' <CODEBASE>');
102 like( $ppd_html, qr{^\s*</IMPLEMENTATION>}m, ' </IMPLEMENTATION>');
103 like( $ppd_html, qr{^\s*</SOFTPKG>}m, ' </SOFTPKG>');
104 END { unlink 'Big-Dummy.ppd' }
107 my $test_out = run("$make test");
108 like( $test_out, qr/All tests successful/, 'make test' );
109 is( $?, 0, ' exited normally' ) ||
112 # Test 'make test TEST_VERBOSE=1'
113 my $make_test_verbose = make_macro($make, 'test', TEST_VERBOSE => 1);
114 $test_out = run("$make_test_verbose");
115 like( $test_out, qr/ok \d+ - TEST_VERBOSE/, 'TEST_VERBOSE' );
116 like( $test_out, qr/All tests successful/, ' successful' );
117 is( $?, 0, ' exited normally' ) ||
121 my $install_out = run("$make install");
122 is( $?, 0, 'install' ) || diag $install_out;
123 like( $install_out, qr/^Installing /m );
124 like( $install_out, qr/^Writing /m );
126 ok( -r '../dummy-install', ' install dir created' );
129 # do it case-insensitive for non-case preserving OSs
130 $files{lc $_} = $File::Find::name;
131 }, '../dummy-install' );
132 ok( $files{'dummy.pm'}, ' Dummy.pm installed' );
133 ok( $files{'liar.pm'}, ' Liar.pm installed' );
134 ok( $files{'.packlist'}, ' packlist created' );
135 ok( $files{'perllocal.pod'},' perllocal.pod created' );
139 skip "VMS install targets do not preserve $(PREFIX)", 8 if $Is_VMS;
141 $install_out = run("$make install PREFIX=elsewhere");
142 is( $?, 0, 'install with PREFIX override' ) || diag $install_out;
143 like( $install_out, qr/^Installing /m );
144 like( $install_out, qr/^Writing /m );
146 ok( -r 'elsewhere', ' install dir created' );
148 find( sub { $files{$_} = $File::Find::name; }, 'elsewhere' );
149 ok( $files{'Dummy.pm'}, ' Dummy.pm installed' );
150 ok( $files{'Liar.pm'}, ' Liar.pm installed' );
151 ok( $files{'.packlist'}, ' packlist created' );
152 ok( $files{'perllocal.pod'},' perllocal.pod created' );
158 skip "VMS install targets do not preserve $(DESTDIR)", 10 if $Is_VMS;
160 $install_out = run("$make install PREFIX= DESTDIR=other");
161 is( $?, 0, 'install with DESTDIR' ) ||
163 like( $install_out, qr/^Installing /m );
164 like( $install_out, qr/^Writing /m );
166 ok( -d 'other', ' destdir created' );
170 $files{$_} = $File::Find::name;
172 ok( $files{'Dummy.pm'}, ' Dummy.pm installed' );
173 ok( $files{'Liar.pm'}, ' Liar.pm installed' );
174 ok( $files{'.packlist'}, ' packlist created' );
175 ok( $files{'perllocal.pod'},' perllocal.pod created' );
177 ok( open(PERLLOCAL, $files{'perllocal.pod'} ) ) ||
178 diag("Can't open $files{'perllocal.pod'}: $!");
180 unlike(<PERLLOCAL>, qr/other/, 'DESTDIR should not appear in perllocal');
184 # TODO not available in the min version of Test::Harness we require
185 # ok( open(PACKLIST, $files{'.packlist'} ) ) ||
186 # diag("Can't open $files{'.packlist'}: $!");
188 # local $TODO = 'DESTDIR still in .packlist';
189 # unlike(<PACKLIST>, qr/other/, 'DESTDIR should not appear in .packlist');
198 skip "VMS install targets do not preserve $(PREFIX)", 9 if $Is_VMS;
200 $install_out = run("$make install PREFIX=elsewhere DESTDIR=other/");
201 is( $?, 0, 'install with PREFIX override and DESTDIR' ) ||
203 like( $install_out, qr/^Installing /m );
204 like( $install_out, qr/^Writing /m );
206 ok( !-d 'elsewhere', ' install dir not created' );
207 ok( -d 'other/elsewhere', ' destdir created' );
209 find( sub { $files{$_} = $File::Find::name; }, 'other/elsewhere' );
210 ok( $files{'Dummy.pm'}, ' Dummy.pm installed' );
211 ok( $files{'Liar.pm'}, ' Liar.pm installed' );
212 ok( $files{'.packlist'}, ' packlist created' );
213 ok( $files{'perllocal.pod'},' perllocal.pod created' );
218 my $dist_test_out = run("$make disttest");
219 is( $?, 0, 'disttest' ) || diag($dist_test_out);
221 # Test META.yml generation
222 use ExtUtils::Manifest qw(maniread);
223 ok( -f 'META.yml', 'META.yml written' );
224 my $manifest = maniread();
225 # VMS is non-case preserving, so we can't know what the MANIFEST will
227 _normalize($manifest);
228 is( $manifest->{'meta.yml'}, 'Module meta-data (added by MakeMaker)' );
230 # Test NO_META META.yml suppression
232 ok( !-f 'META.yml', 'META.yml deleted' );
233 @mpl_out = run(qq{$perl Makefile.PL "NO_META=1"});
234 cmp_ok( $?, '==', 0, 'Makefile.PL exited with zero' ) || diag(@mpl_out);
235 my $metafile_out = run("$make metafile");
236 is( $?, 0, 'metafile' ) || diag($metafile_out);
237 ok( !-f 'META.yml', 'META.yml generation suppressed by NO_META' );
239 # Test if MANIFEST is read-only.
240 chmod 0444, 'MANIFEST';
241 @mpl_out = run(qq{$perl Makefile.PL});
242 cmp_ok( $?, '==', 0, 'Makefile.PL exited with zero' ) || diag(@mpl_out);
243 $metafile_out = run("$make metafile_addtomanifest");
244 is( $?, 0, q{metafile_addtomanifest didn't die with locked MANIFEST} ) ||
248 # Make sure init_dirscan doesn't go into the distdir
249 @mpl_out = run(qq{$perl Makefile.PL "PREFIX=../dummy-install"});
251 cmp_ok( $?, '==', 0, 'Makefile.PL exited with zero' ) || diag(@mpl_out);
253 ok( grep(/^Writing $makefile for Big::Dummy/, @mpl_out) == 1,
254 'init_dirscan skipped distdir') ||
257 # I know we'll get ignored errors from make here, that's ok.
258 # Send STDERR off to oblivion.
259 open(SAVERR, ">&STDERR") or die $!;
260 open(STDERR, ">".File::Spec->devnull) or die $!;
262 my $realclean_out = run("$make realclean");
263 is( $?, 0, 'realclean' ) || diag($realclean_out);
265 open(STDERR, ">&SAVERR") or die $!;
272 while(my($k,$v) = each %$hash) {