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 => 83;
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 # GNV logical interferes with testing
34 $ENV{'bin'} = '[.bin]' if $Is_VMS;
40 my $Touch_Time = calibrate_mtime();
44 ok( setup_recurs(), 'setup' );
46 ok( chdir File::Spec->updir );
47 ok( teardown_recurs(), 'teardown' );
50 ok( chdir('Big-Dummy'), "chdir'd to Big-Dummy" ) ||
51 diag("chdir failed: $!");
53 my @mpl_out = run(qq{$perl Makefile.PL "PREFIX=../dummy-install"});
54 END { rmtree '../dummy-install'; }
56 cmp_ok( $?, '==', 0, 'Makefile.PL exited with zero' ) ||
59 my $makefile = makefile_name();
60 ok( grep(/^Writing $makefile for Big::Dummy/,
62 'Makefile.PL output looks right');
64 ok( grep(/^Current package is: main$/,
66 'Makefile.PL run in package main');
68 ok( -e $makefile, 'Makefile exists' );
71 my $mtime = (stat($makefile))[9];
72 cmp_ok( $Touch_Time, '<=', $mtime, ' its been touched' );
74 END { unlink makefile_name(), makefile_backup() }
76 my $make = make_run();
79 # Supress 'make manifest' noise
80 local $ENV{PERL_MM_MANIFEST_VERBOSE} = 0;
81 my $manifest_out = run("$make manifest");
82 ok( -e 'MANIFEST', 'make manifest created a MANIFEST' );
83 ok( -s 'MANIFEST', ' its not empty' );
86 END { unlink 'MANIFEST'; }
89 my $ppd_out = run("$make ppd");
90 is( $?, 0, ' exited normally' ) || diag $ppd_out;
91 ok( open(PPD, 'Big-Dummy.ppd'), ' .ppd file generated' );
93 { local $/; $ppd_html = <PPD> }
95 like( $ppd_html, qr{^<SOFTPKG NAME="Big-Dummy" VERSION="0,01,0,0">}m,
97 like( $ppd_html, qr{^\s*<TITLE>Big-Dummy</TITLE>}m, ' <TITLE>' );
98 like( $ppd_html, qr{^\s*<ABSTRACT>Try "our" hot dog's</ABSTRACT>}m,
101 qr{^\s*<AUTHOR>Michael G Schwern <schwern\@pobox.com></AUTHOR>}m,
103 like( $ppd_html, qr{^\s*<IMPLEMENTATION>}m, ' <IMPLEMENTATION>');
104 like( $ppd_html, qr{^\s*<DEPENDENCY NAME="strict" VERSION="0,0,0,0" />}m,
106 like( $ppd_html, qr{^\s*<OS NAME="$Config{osname}" />}m,
108 my $archname = $Config{archname};
109 $archname .= "-". substr($Config{version},0,3) if $] >= 5.008;
110 like( $ppd_html, qr{^\s*<ARCHITECTURE NAME="$archname" />}m,
112 like( $ppd_html, qr{^\s*<CODEBASE HREF="" />}m, ' <CODEBASE>');
113 like( $ppd_html, qr{^\s*</IMPLEMENTATION>}m, ' </IMPLEMENTATION>');
114 like( $ppd_html, qr{^\s*</SOFTPKG>}m, ' </SOFTPKG>');
115 END { unlink 'Big-Dummy.ppd' }
118 my $test_out = run("$make test");
119 like( $test_out, qr/All tests successful/, 'make test' );
120 is( $?, 0, ' exited normally' ) ||
123 # Test 'make test TEST_VERBOSE=1'
124 my $make_test_verbose = make_macro($make, 'test', TEST_VERBOSE => 1);
125 $test_out = run("$make_test_verbose");
126 like( $test_out, qr/ok \d+ - TEST_VERBOSE/, 'TEST_VERBOSE' );
127 like( $test_out, qr/All tests successful/, ' successful' );
128 is( $?, 0, ' exited normally' ) ||
132 my $install_out = run("$make install");
133 is( $?, 0, 'install' ) || diag $install_out;
134 like( $install_out, qr/^Installing /m );
135 like( $install_out, qr/^Writing /m );
137 ok( -r '../dummy-install', ' install dir created' );
140 # do it case-insensitive for non-case preserving OSs
143 # VMS likes to put dots on the end of things that don't have them.
144 $file =~ s/\.$// if $Is_VMS;
146 $files{$file} = $File::Find::name;
147 }, '../dummy-install' );
148 ok( $files{'dummy.pm'}, ' Dummy.pm installed' );
149 ok( $files{'liar.pm'}, ' Liar.pm installed' );
150 ok( $files{'program'}, ' program installed' );
151 ok( $files{'.packlist'}, ' packlist created' );
152 ok( $files{'perllocal.pod'},' perllocal.pod created' );
156 skip 'VMS install targets do not preserve $(PREFIX)', 9 if $Is_VMS;
158 $install_out = run("$make install PREFIX=elsewhere");
159 is( $?, 0, 'install with PREFIX override' ) || diag $install_out;
160 like( $install_out, qr/^Installing /m );
161 like( $install_out, qr/^Writing /m );
163 ok( -r 'elsewhere', ' install dir created' );
165 find( sub { $files{$_} = $File::Find::name; }, 'elsewhere' );
166 ok( $files{'Dummy.pm'}, ' Dummy.pm installed' );
167 ok( $files{'Liar.pm'}, ' Liar.pm installed' );
168 ok( $files{'program'}, ' program installed' );
169 ok( $files{'.packlist'}, ' packlist created' );
170 ok( $files{'perllocal.pod'},' perllocal.pod created' );
176 skip 'VMS install targets do not preserve $(DESTDIR)', 11 if $Is_VMS;
178 $install_out = run("$make install PREFIX= DESTDIR=other");
179 is( $?, 0, 'install with DESTDIR' ) ||
181 like( $install_out, qr/^Installing /m );
182 like( $install_out, qr/^Writing /m );
184 ok( -d 'other', ' destdir created' );
188 $files{$_} = $File::Find::name;
190 ok( $files{'Dummy.pm'}, ' Dummy.pm installed' );
191 ok( $files{'Liar.pm'}, ' Liar.pm installed' );
192 ok( $files{'program'}, ' program installed' );
193 ok( $files{'.packlist'}, ' packlist created' );
194 ok( $files{'perllocal.pod'},' perllocal.pod created' );
196 ok( open(PERLLOCAL, $files{'perllocal.pod'} ) ) ||
197 diag("Can't open $files{'perllocal.pod'}: $!");
199 unlike(<PERLLOCAL>, qr/other/, 'DESTDIR should not appear in perllocal');
203 # TODO not available in the min version of Test::Harness we require
204 # ok( open(PACKLIST, $files{'.packlist'} ) ) ||
205 # diag("Can't open $files{'.packlist'}: $!");
207 # local $TODO = 'DESTDIR still in .packlist';
208 # unlike(<PACKLIST>, qr/other/, 'DESTDIR should not appear in .packlist');
217 skip 'VMS install targets do not preserve $(PREFIX)', 10 if $Is_VMS;
219 $install_out = run("$make install PREFIX=elsewhere DESTDIR=other/");
220 is( $?, 0, 'install with PREFIX override and DESTDIR' ) ||
222 like( $install_out, qr/^Installing /m );
223 like( $install_out, qr/^Writing /m );
225 ok( !-d 'elsewhere', ' install dir not created' );
226 ok( -d 'other/elsewhere', ' destdir created' );
228 find( sub { $files{$_} = $File::Find::name; }, 'other/elsewhere' );
229 ok( $files{'Dummy.pm'}, ' Dummy.pm installed' );
230 ok( $files{'Liar.pm'}, ' Liar.pm installed' );
231 ok( $files{'program'}, ' program installed' );
232 ok( $files{'.packlist'}, ' packlist created' );
233 ok( $files{'perllocal.pod'},' perllocal.pod created' );
238 my $dist_test_out = run("$make disttest");
239 is( $?, 0, 'disttest' ) || diag($dist_test_out);
241 # Test META.yml generation
242 use ExtUtils::Manifest qw(maniread);
244 my $distdir = 'Big-Dummy-0.01';
245 $distdir =~ s/\./_/g if $Is_VMS;
246 my $meta_yml = "$distdir/META.yml";
248 ok( !-f 'META.yml', 'META.yml not written to source dir' );
249 ok( -f $meta_yml, 'META.yml written to dist dir' );
250 ok( !-e "META_new.yml", 'temp META.yml file not left around' );
252 ok open META, $meta_yml or diag $!;
254 like $meta[-1], '/\n$/', "META.yml ends with a newline";
257 my $manifest = maniread("$distdir/MANIFEST");
258 # VMS is non-case preserving, so we can't know what the MANIFEST will
260 _normalize($manifest);
261 is( $manifest->{'meta.yml'}, 'Module meta-data (added by MakeMaker)' );
264 # Test NO_META META.yml suppression
266 ok( !-f $meta_yml, 'META.yml deleted' );
267 @mpl_out = run(qq{$perl Makefile.PL "NO_META=1"});
268 cmp_ok( $?, '==', 0, 'Makefile.PL exited with zero' ) || diag(@mpl_out);
269 my $distdir_out = run("$make distdir");
270 is( $?, 0, 'distdir' ) || diag($distdir_out);
271 ok( !-f $meta_yml, 'META.yml generation suppressed by NO_META' );
274 # Make sure init_dirscan doesn't go into the distdir
275 @mpl_out = run(qq{$perl Makefile.PL "PREFIX=../dummy-install"});
277 cmp_ok( $?, '==', 0, 'Makefile.PL exited with zero' ) || diag(@mpl_out);
279 ok( grep(/^Writing $makefile for Big::Dummy/, @mpl_out) == 1,
280 'init_dirscan skipped distdir') ||
283 # I know we'll get ignored errors from make here, that's ok.
284 # Send STDERR off to oblivion.
285 open(SAVERR, ">&STDERR") or die $!;
286 open(STDERR, ">".File::Spec->devnull) or die $!;
288 my $realclean_out = run("$make realclean");
289 is( $?, 0, 'realclean' ) || diag($realclean_out);
291 open(STDERR, ">&SAVERR") or die $!;
298 while(my($k,$v) = each %$hash) {