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';
18 use ExtUtils::MakeMaker;
20 use Test::More tests => 83;
21 use MakeMaker::Test::Utils;
22 use MakeMaker::Test::Setup::BFD;
27 # 'make disttest' sets a bunch of environment variables which interfere
29 delete @ENV{qw(PREFIX LIB MAKEFLAGS)};
31 my $perl = which_perl();
32 my $Is_VMS = $^O eq 'VMS';
34 # GNV logical interferes with testing
35 $ENV{'bin'} = '[.bin]' if $Is_VMS;
41 my $Touch_Time = calibrate_mtime();
45 ok( setup_recurs(), 'setup' );
47 ok( chdir File::Spec->updir );
48 ok( teardown_recurs(), 'teardown' );
51 ok( chdir('Big-Dummy'), "chdir'd to Big-Dummy" ) ||
52 diag("chdir failed: $!");
54 my @mpl_out = run(qq{$perl Makefile.PL "PREFIX=../dummy-install"});
55 END { rmtree '../dummy-install'; }
57 cmp_ok( $?, '==', 0, 'Makefile.PL exited with zero' ) ||
60 my $makefile = makefile_name();
61 ok( grep(/^Writing $makefile for Big::Dummy/,
63 'Makefile.PL output looks right');
65 ok( grep(/^Current package is: main$/,
67 'Makefile.PL run in package main');
69 ok( -e $makefile, 'Makefile exists' );
72 my $mtime = (stat($makefile))[9];
73 cmp_ok( $Touch_Time, '<=', $mtime, ' its been touched' );
75 END { unlink makefile_name(), makefile_backup() }
77 my $make = make_run();
80 # Supress 'make manifest' noise
81 local $ENV{PERL_MM_MANIFEST_VERBOSE} = 0;
82 my $manifest_out = run("$make manifest");
83 ok( -e 'MANIFEST', 'make manifest created a MANIFEST' );
84 ok( -s 'MANIFEST', ' its not empty' );
87 END { unlink 'MANIFEST'; }
90 my $ppd_out = run("$make ppd");
91 is( $?, 0, ' exited normally' ) || diag $ppd_out;
92 ok( open(PPD, 'Big-Dummy.ppd'), ' .ppd file generated' );
94 { local $/; $ppd_html = <PPD> }
96 like( $ppd_html, qr{^<SOFTPKG NAME="Big-Dummy" VERSION="0,01,0,0">}m,
98 like( $ppd_html, qr{^\s*<TITLE>Big-Dummy</TITLE>}m, ' <TITLE>' );
99 like( $ppd_html, qr{^\s*<ABSTRACT>Try "our" hot dog's</ABSTRACT>}m,
102 qr{^\s*<AUTHOR>Michael G Schwern <schwern\@pobox.com></AUTHOR>}m,
104 like( $ppd_html, qr{^\s*<IMPLEMENTATION>}m, ' <IMPLEMENTATION>');
105 like( $ppd_html, qr{^\s*<DEPENDENCY NAME="strict" VERSION="0,0,0,0" />}m,
107 like( $ppd_html, qr{^\s*<OS NAME="$Config{osname}" />}m,
109 my $archname = $Config{archname};
110 $archname .= "-". substr($Config{version},0,3) if $] >= 5.008;
111 like( $ppd_html, qr{^\s*<ARCHITECTURE NAME="$archname" />}m,
113 like( $ppd_html, qr{^\s*<CODEBASE HREF="" />}m, ' <CODEBASE>');
114 like( $ppd_html, qr{^\s*</IMPLEMENTATION>}m, ' </IMPLEMENTATION>');
115 like( $ppd_html, qr{^\s*</SOFTPKG>}m, ' </SOFTPKG>');
116 END { unlink 'Big-Dummy.ppd' }
119 my $test_out = run("$make test");
120 like( $test_out, qr/All tests successful/, 'make test' );
121 is( $?, 0, ' exited normally' ) ||
124 # Test 'make test TEST_VERBOSE=1'
125 my $make_test_verbose = make_macro($make, 'test', TEST_VERBOSE => 1);
126 $test_out = run("$make_test_verbose");
127 like( $test_out, qr/ok \d+ - TEST_VERBOSE/, 'TEST_VERBOSE' );
128 like( $test_out, qr/All tests successful/, ' successful' );
129 is( $?, 0, ' exited normally' ) ||
133 my $install_out = run("$make install");
134 is( $?, 0, 'install' ) || diag $install_out;
135 like( $install_out, qr/^Installing /m );
136 like( $install_out, qr/^Writing /m );
138 ok( -r '../dummy-install', ' install dir created' );
141 # do it case-insensitive for non-case preserving OSs
144 # VMS likes to put dots on the end of things that don't have them.
145 $file =~ s/\.$// if $Is_VMS;
147 $files{$file} = $File::Find::name;
148 }, '../dummy-install' );
149 ok( $files{'dummy.pm'}, ' Dummy.pm installed' );
150 ok( $files{'liar.pm'}, ' Liar.pm installed' );
151 ok( $files{'program'}, ' program installed' );
152 ok( $files{'.packlist'}, ' packlist created' );
153 ok( $files{'perllocal.pod'},' perllocal.pod created' );
157 skip 'VMS install targets do not preserve $(PREFIX)', 9 if $Is_VMS;
159 $install_out = run("$make install PREFIX=elsewhere");
160 is( $?, 0, 'install with PREFIX override' ) || diag $install_out;
161 like( $install_out, qr/^Installing /m );
162 like( $install_out, qr/^Writing /m );
164 ok( -r 'elsewhere', ' install dir created' );
166 find( sub { $files{$_} = $File::Find::name; }, 'elsewhere' );
167 ok( $files{'Dummy.pm'}, ' Dummy.pm installed' );
168 ok( $files{'Liar.pm'}, ' Liar.pm installed' );
169 ok( $files{'program'}, ' program installed' );
170 ok( $files{'.packlist'}, ' packlist created' );
171 ok( $files{'perllocal.pod'},' perllocal.pod created' );
177 skip 'VMS install targets do not preserve $(DESTDIR)', 11 if $Is_VMS;
179 $install_out = run("$make install PREFIX= DESTDIR=other");
180 is( $?, 0, 'install with DESTDIR' ) ||
182 like( $install_out, qr/^Installing /m );
183 like( $install_out, qr/^Writing /m );
185 ok( -d 'other', ' destdir created' );
189 $files{$_} = $File::Find::name;
191 ok( $files{'Dummy.pm'}, ' Dummy.pm installed' );
192 ok( $files{'Liar.pm'}, ' Liar.pm installed' );
193 ok( $files{'program'}, ' program installed' );
194 ok( $files{'.packlist'}, ' packlist created' );
195 ok( $files{'perllocal.pod'},' perllocal.pod created' );
197 ok( open(PERLLOCAL, $files{'perllocal.pod'} ) ) ||
198 diag("Can't open $files{'perllocal.pod'}: $!");
200 unlike(<PERLLOCAL>, qr/other/, 'DESTDIR should not appear in perllocal');
204 # TODO not available in the min version of Test::Harness we require
205 # ok( open(PACKLIST, $files{'.packlist'} ) ) ||
206 # diag("Can't open $files{'.packlist'}: $!");
208 # local $TODO = 'DESTDIR still in .packlist';
209 # unlike(<PACKLIST>, qr/other/, 'DESTDIR should not appear in .packlist');
218 skip 'VMS install targets do not preserve $(PREFIX)', 10 if $Is_VMS;
220 $install_out = run("$make install PREFIX=elsewhere DESTDIR=other/");
221 is( $?, 0, 'install with PREFIX override and DESTDIR' ) ||
223 like( $install_out, qr/^Installing /m );
224 like( $install_out, qr/^Writing /m );
226 ok( !-d 'elsewhere', ' install dir not created' );
227 ok( -d 'other/elsewhere', ' destdir created' );
229 find( sub { $files{$_} = $File::Find::name; }, 'other/elsewhere' );
230 ok( $files{'Dummy.pm'}, ' Dummy.pm installed' );
231 ok( $files{'Liar.pm'}, ' Liar.pm installed' );
232 ok( $files{'program'}, ' program installed' );
233 ok( $files{'.packlist'}, ' packlist created' );
234 ok( $files{'perllocal.pod'},' perllocal.pod created' );
239 my $dist_test_out = run("$make disttest");
240 is( $?, 0, 'disttest' ) || diag($dist_test_out);
242 # Test META.yml generation
243 use ExtUtils::Manifest qw(maniread);
245 my $distdir = 'Big-Dummy-0.01';
246 $distdir =~ s/\./_/g if $Is_VMS;
247 my $meta_yml = "$distdir/META.yml";
249 ok( !-f 'META.yml', 'META.yml not written to source dir' );
250 ok( -f $meta_yml, 'META.yml written to dist dir' );
251 ok( !-e "META_new.yml", 'temp META.yml file not left around' );
253 ok open META, $meta_yml or diag $!;
254 my $meta = join '', <META>;
261 abstract: Try "our" hot dog's
264 - Michael G Schwern <schwern\@pobox.com>
265 generated_by: ExtUtils::MakeMaker version $ExtUtils::MakeMaker::VERSION
266 distribution_type: module
270 url: http://module-build.sourceforge.net/META-spec-v1.3.html
274 my $manifest = maniread("$distdir/MANIFEST");
275 # VMS is non-case preserving, so we can't know what the MANIFEST will
277 _normalize($manifest);
278 is( $manifest->{'meta.yml'}, 'Module meta-data (added by MakeMaker)' );
281 # Test NO_META META.yml suppression
283 ok( !-f $meta_yml, 'META.yml deleted' );
284 @mpl_out = run(qq{$perl Makefile.PL "NO_META=1"});
285 cmp_ok( $?, '==', 0, 'Makefile.PL exited with zero' ) || diag(@mpl_out);
286 my $distdir_out = run("$make distdir");
287 is( $?, 0, 'distdir' ) || diag($distdir_out);
288 ok( !-f $meta_yml, 'META.yml generation suppressed by NO_META' );
291 # Make sure init_dirscan doesn't go into the distdir
292 @mpl_out = run(qq{$perl Makefile.PL "PREFIX=../dummy-install"});
294 cmp_ok( $?, '==', 0, 'Makefile.PL exited with zero' ) || diag(@mpl_out);
296 ok( grep(/^Writing $makefile for Big::Dummy/, @mpl_out) == 1,
297 'init_dirscan skipped distdir') ||
300 # I know we'll get ignored errors from make here, that's ok.
301 # Send STDERR off to oblivion.
302 open(SAVERR, ">&STDERR") or die $!;
303 open(STDERR, ">".File::Spec->devnull) or die $!;
305 my $realclean_out = run("$make realclean");
306 is( $?, 0, 'realclean' ) || diag($realclean_out);
308 open(STDERR, ">&SAVERR") or die $!;
315 while(my($k,$v) = each %$hash) {