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 => 80;
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>' );
92 unlike( $ppd_html, qr{^\s*<REQUIRE NAME="warnings::" />}m, 'no <REQUIRE> for build_require' );
94 my $archname = $Config{archname};
96 # XXX This is a copy of the internal logic, so it's not a great test
97 $archname .= "-$Config{PERL_REVISION}.$Config{PERL_VERSION}";
99 like( $ppd_html, qr{^\s*<ARCHITECTURE NAME="$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 );
125 ok( -r '../dummy-install', ' install dir created' );
128 # do it case-insensitive for non-case preserving OSs
131 # VMS likes to put dots on the end of things that don't have them.
132 $file =~ s/\.$// if $Is_VMS;
134 $files{$file} = $File::Find::name;
135 }, '../dummy-install' );
136 ok( $files{'dummy.pm'}, ' Dummy.pm installed' );
137 ok( $files{'liar.pm'}, ' Liar.pm installed' );
138 ok( $files{'program'}, ' program installed' );
139 ok( $files{'.packlist'}, ' packlist created' );
140 ok( $files{'perllocal.pod'},' perllocal.pod created' );
144 skip 'VMS install targets do not preserve $(PREFIX)', 8 if $Is_VMS;
146 $install_out = run("$make install PREFIX=elsewhere");
147 is( $?, 0, 'install with PREFIX override' ) || diag $install_out;
148 like( $install_out, qr/^Installing /m );
150 ok( -r 'elsewhere', ' install dir created' );
152 find( sub { $files{$_} = $File::Find::name; }, 'elsewhere' );
153 ok( $files{'Dummy.pm'}, ' Dummy.pm installed' );
154 ok( $files{'Liar.pm'}, ' Liar.pm installed' );
155 ok( $files{'program'}, ' program installed' );
156 ok( $files{'.packlist'}, ' packlist created' );
157 ok( $files{'perllocal.pod'},' perllocal.pod created' );
163 skip 'VMS install targets do not preserve $(DESTDIR)', 10 if $Is_VMS;
165 $install_out = run("$make install PREFIX= DESTDIR=other");
166 is( $?, 0, 'install with DESTDIR' ) ||
168 like( $install_out, qr/^Installing /m );
170 ok( -d 'other', ' destdir created' );
174 $files{$_} = $File::Find::name;
176 ok( $files{'Dummy.pm'}, ' Dummy.pm installed' );
177 ok( $files{'Liar.pm'}, ' Liar.pm installed' );
178 ok( $files{'program'}, ' program installed' );
179 ok( $files{'.packlist'}, ' packlist created' );
180 ok( $files{'perllocal.pod'},' perllocal.pod created' );
182 ok( open(PERLLOCAL, $files{'perllocal.pod'} ) ) ||
183 diag("Can't open $files{'perllocal.pod'}: $!");
185 unlike(<PERLLOCAL>, qr/other/, 'DESTDIR should not appear in perllocal');
189 # TODO not available in the min version of Test::Harness we require
190 # ok( open(PACKLIST, $files{'.packlist'} ) ) ||
191 # diag("Can't open $files{'.packlist'}: $!");
193 # local $TODO = 'DESTDIR still in .packlist';
194 # unlike(<PACKLIST>, qr/other/, 'DESTDIR should not appear in .packlist');
203 skip 'VMS install targets do not preserve $(PREFIX)', 9 if $Is_VMS;
205 $install_out = run("$make install PREFIX=elsewhere DESTDIR=other/");
206 is( $?, 0, 'install with PREFIX override and DESTDIR' ) ||
208 like( $install_out, qr/^Installing /m );
210 ok( !-d 'elsewhere', ' install dir not created' );
211 ok( -d 'other/elsewhere', ' destdir created' );
213 find( sub { $files{$_} = $File::Find::name; }, 'other/elsewhere' );
214 ok( $files{'Dummy.pm'}, ' Dummy.pm installed' );
215 ok( $files{'Liar.pm'}, ' Liar.pm installed' );
216 ok( $files{'program'}, ' program installed' );
217 ok( $files{'.packlist'}, ' packlist created' );
218 ok( $files{'perllocal.pod'},' perllocal.pod created' );
223 my $dist_test_out = run("$make disttest");
224 is( $?, 0, 'disttest' ) || diag($dist_test_out);
226 # Test META.yml generation
227 use ExtUtils::Manifest qw(maniread);
229 my $distdir = 'Big-Dummy-0.01';
230 $distdir =~ s/\./_/g if $Is_VMS;
231 my $meta_yml = "$distdir/META.yml";
233 ok( !-f 'META.yml', 'META.yml not written to source dir' );
234 ok( -f $meta_yml, 'META.yml written to dist dir' );
235 ok( !-e "META_new.yml", 'temp META.yml file not left around' );
238 # META.yml spec 1.4 was added in 0.11
239 skip "Test::YAML::Meta >= 0.11 required", 2
240 unless eval { require Test::YAML::Meta } and
241 Test::YAML::Meta->VERSION >= 0.11;
243 Test::YAML::Meta::meta_spec_ok($meta_yml);
246 ok open META, $meta_yml or diag $!;
247 my $meta = join '', <META>;
254 abstract: Try "our" hot dog's
256 - Michael G Schwern <schwern\@pobox.com>
258 distribution_type: module
260 ExtUtils::MakeMaker: 0
269 generated_by: ExtUtils::MakeMaker version $ExtUtils::MakeMaker::VERSION
271 url: http://module-build.sourceforge.net/META-spec-v1.4.html
275 my $manifest = maniread("$distdir/MANIFEST");
276 # VMS is non-case preserving, so we can't know what the MANIFEST will
278 _normalize($manifest);
279 is( $manifest->{'meta.yml'}, 'Module meta-data (added by MakeMaker)' );
282 # Test NO_META META.yml suppression
284 ok( !-f $meta_yml, 'META.yml deleted' );
285 @mpl_out = run(qq{$perl Makefile.PL "NO_META=1"});
286 cmp_ok( $?, '==', 0, 'Makefile.PL exited with zero' ) || diag(@mpl_out);
287 my $distdir_out = run("$make distdir");
288 is( $?, 0, 'distdir' ) || diag($distdir_out);
289 ok( !-f $meta_yml, 'META.yml generation suppressed by NO_META' );
292 # Make sure init_dirscan doesn't go into the distdir
293 @mpl_out = run(qq{$perl Makefile.PL "PREFIX=../dummy-install"});
295 cmp_ok( $?, '==', 0, 'Makefile.PL exited with zero' ) || diag(@mpl_out);
297 ok( grep(/^Writing $makefile for Big::Dummy/, @mpl_out) == 1,
298 'init_dirscan skipped distdir') ||
301 # I know we'll get ignored errors from make here, that's ok.
302 # Send STDERR off to oblivion.
303 open(SAVERR, ">&STDERR") or die $!;
304 open(STDERR, ">",File::Spec->devnull) or die $!;
306 my $realclean_out = run("$make realclean");
307 is( $?, 0, 'realclean' ) || diag($realclean_out);
309 open(STDERR, ">&SAVERR") or die $!;
316 while(my($k,$v) = each %$hash) {