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 => 80;
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';
37 my $Touch_Time = calibrate_mtime();
41 ok( setup_recurs(), 'setup' );
43 ok( chdir File::Spec->updir );
44 ok( teardown_recurs(), 'teardown' );
47 ok( chdir('Big-Dummy'), "chdir'd to Big-Dummy" ) ||
48 diag("chdir failed: $!");
50 my @mpl_out = run(qq{$perl Makefile.PL "PREFIX=../dummy-install"});
51 END { rmtree '../dummy-install'; }
53 cmp_ok( $?, '==', 0, 'Makefile.PL exited with zero' ) ||
56 my $makefile = makefile_name();
57 ok( grep(/^Writing $makefile for Big::Dummy/,
59 'Makefile.PL output looks right');
61 ok( grep(/^Current package is: main$/,
63 'Makefile.PL run in package main');
65 ok( -e $makefile, 'Makefile exists' );
68 my $mtime = (stat($makefile))[9];
69 cmp_ok( $Touch_Time, '<=', $mtime, ' its been touched' );
71 END { unlink makefile_name(), makefile_backup() }
73 my $make = make_run();
76 # Supress 'make manifest' noise
77 local $ENV{PERL_MM_MANIFEST_VERBOSE} = 0;
78 my $manifest_out = run("$make manifest");
79 ok( -e 'MANIFEST', 'make manifest created a MANIFEST' );
80 ok( -s 'MANIFEST', ' its not empty' );
83 END { unlink 'MANIFEST'; }
86 my $ppd_out = run("$make ppd");
87 is( $?, 0, ' exited normally' ) || diag $ppd_out;
88 ok( open(PPD, 'Big-Dummy.ppd'), ' .ppd file generated' );
90 { local $/; $ppd_html = <PPD> }
92 like( $ppd_html, qr{^<SOFTPKG NAME="Big-Dummy" VERSION="0,01,0,0">}m,
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,
98 qr{^\s*<AUTHOR>Michael G Schwern <schwern\@pobox.com></AUTHOR>}m,
100 like( $ppd_html, qr{^\s*<IMPLEMENTATION>}m, ' <IMPLEMENTATION>');
101 like( $ppd_html, qr{^\s*<DEPENDENCY NAME="strict" VERSION="0,0,0,0" />}m,
103 like( $ppd_html, qr{^\s*<OS NAME="$Config{osname}" />}m,
105 like( $ppd_html, qr{^\s*<ARCHITECTURE NAME="$Config{archname}" />}m,
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' }
113 my $test_out = run("$make test");
114 like( $test_out, qr/All tests successful/, 'make test' );
115 is( $?, 0, ' exited normally' ) ||
118 # Test 'make test TEST_VERBOSE=1'
119 my $make_test_verbose = make_macro($make, 'test', TEST_VERBOSE => 1);
120 $test_out = run("$make_test_verbose");
121 like( $test_out, qr/ok \d+ - TEST_VERBOSE/, 'TEST_VERBOSE' );
122 like( $test_out, qr/All tests successful/, ' successful' );
123 is( $?, 0, ' exited normally' ) ||
127 my $install_out = run("$make install");
128 is( $?, 0, 'install' ) || diag $install_out;
129 like( $install_out, qr/^Installing /m );
130 like( $install_out, qr/^Writing /m );
132 ok( -r '../dummy-install', ' install dir created' );
135 # do it case-insensitive for non-case preserving OSs
138 # VMS likes to put dots on the end of things that don't have them.
139 $file =~ s/\.$// if $Is_VMS;
141 $files{$file} = $File::Find::name;
142 }, '../dummy-install' );
143 ok( $files{'dummy.pm'}, ' Dummy.pm installed' );
144 ok( $files{'liar.pm'}, ' Liar.pm installed' );
145 ok( $files{'program'}, ' program installed' );
146 ok( $files{'.packlist'}, ' packlist created' );
147 ok( $files{'perllocal.pod'},' perllocal.pod created' );
151 skip 'VMS install targets do not preserve $(PREFIX)', 9 if $Is_VMS;
153 $install_out = run("$make install PREFIX=elsewhere");
154 is( $?, 0, 'install with PREFIX override' ) || diag $install_out;
155 like( $install_out, qr/^Installing /m );
156 like( $install_out, qr/^Writing /m );
158 ok( -r 'elsewhere', ' install dir created' );
160 find( sub { $files{$_} = $File::Find::name; }, 'elsewhere' );
161 ok( $files{'Dummy.pm'}, ' Dummy.pm installed' );
162 ok( $files{'Liar.pm'}, ' Liar.pm installed' );
163 ok( $files{'program'}, ' program installed' );
164 ok( $files{'.packlist'}, ' packlist created' );
165 ok( $files{'perllocal.pod'},' perllocal.pod created' );
171 skip 'VMS install targets do not preserve $(DESTDIR)', 11 if $Is_VMS;
173 $install_out = run("$make install PREFIX= DESTDIR=other");
174 is( $?, 0, 'install with DESTDIR' ) ||
176 like( $install_out, qr/^Installing /m );
177 like( $install_out, qr/^Writing /m );
179 ok( -d 'other', ' destdir created' );
183 $files{$_} = $File::Find::name;
185 ok( $files{'Dummy.pm'}, ' Dummy.pm installed' );
186 ok( $files{'Liar.pm'}, ' Liar.pm installed' );
187 ok( $files{'program'}, ' program installed' );
188 ok( $files{'.packlist'}, ' packlist created' );
189 ok( $files{'perllocal.pod'},' perllocal.pod created' );
191 ok( open(PERLLOCAL, $files{'perllocal.pod'} ) ) ||
192 diag("Can't open $files{'perllocal.pod'}: $!");
194 unlike(<PERLLOCAL>, qr/other/, 'DESTDIR should not appear in perllocal');
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'}: $!");
202 # local $TODO = 'DESTDIR still in .packlist';
203 # unlike(<PACKLIST>, qr/other/, 'DESTDIR should not appear in .packlist');
212 skip 'VMS install targets do not preserve $(PREFIX)', 10 if $Is_VMS;
214 $install_out = run("$make install PREFIX=elsewhere DESTDIR=other/");
215 is( $?, 0, 'install with PREFIX override and DESTDIR' ) ||
217 like( $install_out, qr/^Installing /m );
218 like( $install_out, qr/^Writing /m );
220 ok( !-d 'elsewhere', ' install dir not created' );
221 ok( -d 'other/elsewhere', ' destdir created' );
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' );
226 ok( $files{'program'}, ' program installed' );
227 ok( $files{'.packlist'}, ' packlist created' );
228 ok( $files{'perllocal.pod'},' perllocal.pod created' );
233 my $dist_test_out = run("$make disttest");
234 is( $?, 0, 'disttest' ) || diag($dist_test_out);
236 # Test META.yml generation
237 use ExtUtils::Manifest qw(maniread);
239 my $distdir = 'Big-Dummy-0.01';
240 $distdir =~ s/\./_/g if $Is_VMS;
241 my $meta_yml = "$distdir/META.yml";
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' );
247 my $manifest = maniread("$distdir/MANIFEST");
248 # VMS is non-case preserving, so we can't know what the MANIFEST will
250 _normalize($manifest);
251 is( $manifest->{'meta.yml'}, 'Module meta-data (added by MakeMaker)' );
254 # Test NO_META META.yml suppression
256 ok( !-f $meta_yml, 'META.yml deleted' );
257 @mpl_out = run(qq{$perl Makefile.PL "NO_META=1"});
258 cmp_ok( $?, '==', 0, 'Makefile.PL exited with zero' ) || diag(@mpl_out);
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' );
264 # Make sure init_dirscan doesn't go into the distdir
265 @mpl_out = run(qq{$perl Makefile.PL "PREFIX=../dummy-install"});
267 cmp_ok( $?, '==', 0, 'Makefile.PL exited with zero' ) || diag(@mpl_out);
269 ok( grep(/^Writing $makefile for Big::Dummy/, @mpl_out) == 1,
270 'init_dirscan skipped distdir') ||
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 $!;
278 my $realclean_out = run("$make realclean");
279 is( $?, 0, 'realclean' ) || diag($realclean_out);
281 open(STDERR, ">&SAVERR") or die $!;
288 while(my($k,$v) = each %$hash) {