3 # This test puts MakeMaker through the paces of a basic perl module
4 # build, test and installation of the Big::Fat::Dummy module.
12 use ExtUtils::MakeMaker;
14 use Test::More tests => 79;
15 use MakeMaker::Test::Utils;
16 use MakeMaker::Test::Setup::BFD;
21 my $perl = which_perl();
22 my $Is_VMS = $^O eq 'VMS';
28 my $Touch_Time = calibrate_mtime();
32 ok( setup_recurs(), 'setup' );
34 ok( chdir File::Spec->updir );
35 ok( teardown_recurs(), 'teardown' );
38 ok( chdir('Big-Dummy'), "chdir'd to Big-Dummy" ) ||
39 diag("chdir failed: $!");
41 my @mpl_out = run(qq{$perl Makefile.PL "PREFIX=../dummy-install"});
42 END { rmtree '../dummy-install'; }
44 cmp_ok( $?, '==', 0, 'Makefile.PL exited with zero' ) ||
47 my $makefile = makefile_name();
48 ok( grep(/^Writing $makefile for Big::Dummy/,
50 'Makefile.PL output looks right');
52 ok( grep(/^Current package is: main$/,
54 'Makefile.PL run in package main');
56 ok( -e $makefile, 'Makefile exists' );
59 my $mtime = (stat($makefile))[9];
60 cmp_ok( $Touch_Time, '<=', $mtime, ' its been touched' );
62 END { unlink makefile_name(), makefile_backup() }
64 my $make = make_run();
67 # Supress 'make manifest' noise
68 local $ENV{PERL_MM_MANIFEST_VERBOSE} = 0;
69 my $manifest_out = run("$make manifest");
70 ok( -e 'MANIFEST', 'make manifest created a MANIFEST' );
71 ok( -s 'MANIFEST', ' its not empty' );
74 END { unlink 'MANIFEST'; }
77 my $ppd_out = run("$make ppd");
78 is( $?, 0, ' exited normally' ) || diag $ppd_out;
79 ok( open(PPD, 'Big-Dummy.ppd'), ' .ppd file generated' );
81 { local $/; $ppd_html = <PPD> }
83 like( $ppd_html, qr{^<SOFTPKG NAME="Big-Dummy" VERSION="0.01">}m,
85 like( $ppd_html, qr{^\s*<ABSTRACT>Try "our" hot dog's</ABSTRACT>}m,
88 qr{^\s*<AUTHOR>Michael G Schwern <schwern\@pobox.com></AUTHOR>}m,
90 like( $ppd_html, qr{^\s*<IMPLEMENTATION>}m, ' <IMPLEMENTATION>');
91 like( $ppd_html, qr{^\s*<REQUIRE NAME="strict::" />}m, ' <REQUIRE>' );
93 my $archname = $Config{archname};
95 # XXX This is a copy of the internal logic, so it's not a great test
96 $archname .= "-$Config{PERL_REVISION}.$Config{PERL_VERSION}";
98 like( $ppd_html, qr{^\s*<ARCHITECTURE NAME="$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' ) ||
111 # Test 'make test TEST_VERBOSE=1'
112 my $make_test_verbose = make_macro($make, 'test', TEST_VERBOSE => 1);
113 $test_out = run("$make_test_verbose");
114 like( $test_out, qr/ok \d+ - TEST_VERBOSE/, 'TEST_VERBOSE' );
115 like( $test_out, qr/All tests successful/, ' successful' );
116 is( $?, 0, ' exited normally' ) ||
120 my $install_out = run("$make install");
121 is( $?, 0, 'install' ) || diag $install_out;
122 like( $install_out, qr/^Installing /m );
124 ok( -r '../dummy-install', ' install dir created' );
127 # do it case-insensitive for non-case preserving OSs
130 # VMS likes to put dots on the end of things that don't have them.
131 $file =~ s/\.$// if $Is_VMS;
133 $files{$file} = $File::Find::name;
134 }, '../dummy-install' );
135 ok( $files{'dummy.pm'}, ' Dummy.pm installed' );
136 ok( $files{'liar.pm'}, ' Liar.pm installed' );
137 ok( $files{'program'}, ' program installed' );
138 ok( $files{'.packlist'}, ' packlist created' );
139 ok( $files{'perllocal.pod'},' perllocal.pod created' );
143 skip 'VMS install targets do not preserve $(PREFIX)', 8 if $Is_VMS;
145 $install_out = run("$make install PREFIX=elsewhere");
146 is( $?, 0, 'install with PREFIX override' ) || diag $install_out;
147 like( $install_out, qr/^Installing /m );
149 ok( -r 'elsewhere', ' install dir created' );
151 find( sub { $files{$_} = $File::Find::name; }, 'elsewhere' );
152 ok( $files{'Dummy.pm'}, ' Dummy.pm installed' );
153 ok( $files{'Liar.pm'}, ' Liar.pm installed' );
154 ok( $files{'program'}, ' program installed' );
155 ok( $files{'.packlist'}, ' packlist created' );
156 ok( $files{'perllocal.pod'},' perllocal.pod created' );
162 skip 'VMS install targets do not preserve $(DESTDIR)', 10 if $Is_VMS;
164 $install_out = run("$make install PREFIX= DESTDIR=other");
165 is( $?, 0, 'install with DESTDIR' ) ||
167 like( $install_out, qr/^Installing /m );
169 ok( -d 'other', ' destdir created' );
173 $files{$_} = $File::Find::name;
175 ok( $files{'Dummy.pm'}, ' Dummy.pm installed' );
176 ok( $files{'Liar.pm'}, ' Liar.pm installed' );
177 ok( $files{'program'}, ' program installed' );
178 ok( $files{'.packlist'}, ' packlist created' );
179 ok( $files{'perllocal.pod'},' perllocal.pod created' );
181 ok( open(PERLLOCAL, $files{'perllocal.pod'} ) ) ||
182 diag("Can't open $files{'perllocal.pod'}: $!");
184 unlike(<PERLLOCAL>, qr/other/, 'DESTDIR should not appear in perllocal');
188 # TODO not available in the min version of Test::Harness we require
189 # ok( open(PACKLIST, $files{'.packlist'} ) ) ||
190 # diag("Can't open $files{'.packlist'}: $!");
192 # local $TODO = 'DESTDIR still in .packlist';
193 # unlike(<PACKLIST>, qr/other/, 'DESTDIR should not appear in .packlist');
202 skip 'VMS install targets do not preserve $(PREFIX)', 9 if $Is_VMS;
204 $install_out = run("$make install PREFIX=elsewhere DESTDIR=other/");
205 is( $?, 0, 'install with PREFIX override and DESTDIR' ) ||
207 like( $install_out, qr/^Installing /m );
209 ok( !-d 'elsewhere', ' install dir not created' );
210 ok( -d 'other/elsewhere', ' destdir created' );
212 find( sub { $files{$_} = $File::Find::name; }, 'other/elsewhere' );
213 ok( $files{'Dummy.pm'}, ' Dummy.pm installed' );
214 ok( $files{'Liar.pm'}, ' Liar.pm installed' );
215 ok( $files{'program'}, ' program installed' );
216 ok( $files{'.packlist'}, ' packlist created' );
217 ok( $files{'perllocal.pod'},' perllocal.pod created' );
222 my $dist_test_out = run("$make disttest");
223 is( $?, 0, 'disttest' ) || diag($dist_test_out);
225 # Test META.yml generation
226 use ExtUtils::Manifest qw(maniread);
228 my $distdir = 'Big-Dummy-0.01';
229 $distdir =~ s/\./_/g if $Is_VMS;
230 my $meta_yml = "$distdir/META.yml";
232 ok( !-f 'META.yml', 'META.yml not written to source dir' );
233 ok( -f $meta_yml, 'META.yml written to dist dir' );
234 ok( !-e "META_new.yml", 'temp META.yml file not left around' );
237 # META.yml spec 1.4 was added in 0.11
238 skip "Test::YAML::Meta >= 0.11 required", 2
239 unless eval { require Test::YAML::Meta } and
240 Test::YAML::Meta->VERSION >= 0.11;
242 Test::YAML::Meta::meta_spec_ok($meta_yml);
245 ok open META, $meta_yml or diag $!;
246 my $meta = join '', <META>;
253 abstract: Try "our" hot dog's
255 - Michael G Schwern <schwern\@pobox.com>
257 distribution_type: module
259 ExtUtils::MakeMaker: 0
261 ExtUtils::MakeMaker: 0
268 generated_by: ExtUtils::MakeMaker version $ExtUtils::MakeMaker::VERSION
270 url: http://module-build.sourceforge.net/META-spec-v1.4.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) {