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 => 79;
21 use MakeMaker::Test::Utils;
22 use MakeMaker::Test::Setup::BFD;
27 my $perl = which_perl();
28 my $Is_VMS = $^O eq 'VMS';
34 my $Touch_Time = calibrate_mtime();
38 ok( setup_recurs(), 'setup' );
40 ok( chdir File::Spec->updir );
41 ok( teardown_recurs(), 'teardown' );
44 ok( chdir('Big-Dummy'), "chdir'd to Big-Dummy" ) ||
45 diag("chdir failed: $!");
47 my @mpl_out = run(qq{$perl Makefile.PL "PREFIX=../dummy-install"});
48 END { rmtree '../dummy-install'; }
50 cmp_ok( $?, '==', 0, 'Makefile.PL exited with zero' ) ||
53 my $makefile = makefile_name();
54 ok( grep(/^Writing $makefile for Big::Dummy/,
56 'Makefile.PL output looks right');
58 ok( grep(/^Current package is: main$/,
60 'Makefile.PL run in package main');
62 ok( -e $makefile, 'Makefile exists' );
65 my $mtime = (stat($makefile))[9];
66 cmp_ok( $Touch_Time, '<=', $mtime, ' its been touched' );
68 END { unlink makefile_name(), makefile_backup() }
70 my $make = make_run();
73 # Supress 'make manifest' noise
74 local $ENV{PERL_MM_MANIFEST_VERBOSE} = 0;
75 my $manifest_out = run("$make manifest");
76 ok( -e 'MANIFEST', 'make manifest created a MANIFEST' );
77 ok( -s 'MANIFEST', ' its not empty' );
80 END { unlink 'MANIFEST'; }
83 my $ppd_out = run("$make ppd");
84 is( $?, 0, ' exited normally' ) || diag $ppd_out;
85 ok( open(PPD, 'Big-Dummy.ppd'), ' .ppd file generated' );
87 { local $/; $ppd_html = <PPD> }
89 like( $ppd_html, qr{^<SOFTPKG NAME="Big-Dummy" VERSION="0.01">}m,
91 like( $ppd_html, qr{^\s*<ABSTRACT>Try "our" hot dog's</ABSTRACT>}m,
94 qr{^\s*<AUTHOR>Michael G Schwern <schwern\@pobox.com></AUTHOR>}m,
96 like( $ppd_html, qr{^\s*<IMPLEMENTATION>}m, ' <IMPLEMENTATION>');
97 like( $ppd_html, qr{^\s*<REQUIRE NAME="strict::" />}m, ' <REQUIRE>' );
99 my $archname = $Config{archname};
101 # XXX This is a copy of the internal logic, so it's not a great test
102 $archname .= "-$Config{PERL_REVISION}.$Config{PERL_VERSION}";
104 like( $ppd_html, qr{^\s*<ARCHITECTURE NAME="$archname" />}m,
106 like( $ppd_html, qr{^\s*<CODEBASE HREF="" />}m, ' <CODEBASE>');
107 like( $ppd_html, qr{^\s*</IMPLEMENTATION>}m, ' </IMPLEMENTATION>');
108 like( $ppd_html, qr{^\s*</SOFTPKG>}m, ' </SOFTPKG>');
109 END { unlink 'Big-Dummy.ppd' }
112 my $test_out = run("$make test");
113 like( $test_out, qr/All tests successful/, 'make test' );
114 is( $?, 0, ' exited normally' ) ||
117 # Test 'make test TEST_VERBOSE=1'
118 my $make_test_verbose = make_macro($make, 'test', TEST_VERBOSE => 1);
119 $test_out = run("$make_test_verbose");
120 like( $test_out, qr/ok \d+ - TEST_VERBOSE/, 'TEST_VERBOSE' );
121 like( $test_out, qr/All tests successful/, ' successful' );
122 is( $?, 0, ' exited normally' ) ||
126 my $install_out = run("$make install");
127 is( $?, 0, 'install' ) || diag $install_out;
128 like( $install_out, qr/^Installing /m );
130 ok( -r '../dummy-install', ' install dir created' );
133 # do it case-insensitive for non-case preserving OSs
136 # VMS likes to put dots on the end of things that don't have them.
137 $file =~ s/\.$// if $Is_VMS;
139 $files{$file} = $File::Find::name;
140 }, '../dummy-install' );
141 ok( $files{'dummy.pm'}, ' Dummy.pm installed' );
142 ok( $files{'liar.pm'}, ' Liar.pm installed' );
143 ok( $files{'program'}, ' program installed' );
144 ok( $files{'.packlist'}, ' packlist created' );
145 ok( $files{'perllocal.pod'},' perllocal.pod created' );
149 skip 'VMS install targets do not preserve $(PREFIX)', 8 if $Is_VMS;
151 $install_out = run("$make install PREFIX=elsewhere");
152 is( $?, 0, 'install with PREFIX override' ) || diag $install_out;
153 like( $install_out, qr/^Installing /m );
155 ok( -r 'elsewhere', ' install dir created' );
157 find( sub { $files{$_} = $File::Find::name; }, 'elsewhere' );
158 ok( $files{'Dummy.pm'}, ' Dummy.pm installed' );
159 ok( $files{'Liar.pm'}, ' Liar.pm installed' );
160 ok( $files{'program'}, ' program installed' );
161 ok( $files{'.packlist'}, ' packlist created' );
162 ok( $files{'perllocal.pod'},' perllocal.pod created' );
168 skip 'VMS install targets do not preserve $(DESTDIR)', 10 if $Is_VMS;
170 $install_out = run("$make install PREFIX= DESTDIR=other");
171 is( $?, 0, 'install with DESTDIR' ) ||
173 like( $install_out, qr/^Installing /m );
175 ok( -d 'other', ' destdir created' );
179 $files{$_} = $File::Find::name;
181 ok( $files{'Dummy.pm'}, ' Dummy.pm installed' );
182 ok( $files{'Liar.pm'}, ' Liar.pm installed' );
183 ok( $files{'program'}, ' program installed' );
184 ok( $files{'.packlist'}, ' packlist created' );
185 ok( $files{'perllocal.pod'},' perllocal.pod created' );
187 ok( open(PERLLOCAL, $files{'perllocal.pod'} ) ) ||
188 diag("Can't open $files{'perllocal.pod'}: $!");
190 unlike(<PERLLOCAL>, qr/other/, 'DESTDIR should not appear in perllocal');
194 # TODO not available in the min version of Test::Harness we require
195 # ok( open(PACKLIST, $files{'.packlist'} ) ) ||
196 # diag("Can't open $files{'.packlist'}: $!");
198 # local $TODO = 'DESTDIR still in .packlist';
199 # unlike(<PACKLIST>, qr/other/, 'DESTDIR should not appear in .packlist');
208 skip 'VMS install targets do not preserve $(PREFIX)', 9 if $Is_VMS;
210 $install_out = run("$make install PREFIX=elsewhere DESTDIR=other/");
211 is( $?, 0, 'install with PREFIX override and DESTDIR' ) ||
213 like( $install_out, qr/^Installing /m );
215 ok( !-d 'elsewhere', ' install dir not created' );
216 ok( -d 'other/elsewhere', ' destdir created' );
218 find( sub { $files{$_} = $File::Find::name; }, 'other/elsewhere' );
219 ok( $files{'Dummy.pm'}, ' Dummy.pm installed' );
220 ok( $files{'Liar.pm'}, ' Liar.pm installed' );
221 ok( $files{'program'}, ' program installed' );
222 ok( $files{'.packlist'}, ' packlist created' );
223 ok( $files{'perllocal.pod'},' perllocal.pod created' );
228 my $dist_test_out = run("$make disttest");
229 is( $?, 0, 'disttest' ) || diag($dist_test_out);
231 # Test META.yml generation
232 use ExtUtils::Manifest qw(maniread);
234 my $distdir = 'Big-Dummy-0.01';
235 $distdir =~ s/\./_/g if $Is_VMS;
236 my $meta_yml = "$distdir/META.yml";
238 ok( !-f 'META.yml', 'META.yml not written to source dir' );
239 ok( -f $meta_yml, 'META.yml written to dist dir' );
240 ok( !-e "META_new.yml", 'temp META.yml file not left around' );
243 # META.yml spec 1.4 was added in 0.11
244 skip "Test::YAML::Meta >= 0.11 required", 2
245 unless eval { require Test::YAML::Meta } and
246 Test::YAML::Meta->VERSION >= 0.11;
248 Test::YAML::Meta::meta_spec_ok($meta_yml);
251 ok open META, $meta_yml or diag $!;
252 my $meta = join '', <META>;
259 abstract: Try "our" hot dog's
261 - Michael G Schwern <schwern\@pobox.com>
263 distribution_type: module
265 ExtUtils::MakeMaker: 0
267 ExtUtils::MakeMaker: 0
274 generated_by: ExtUtils::MakeMaker version $ExtUtils::MakeMaker::VERSION
276 url: http://module-build.sourceforge.net/META-spec-v1.4.html
280 my $manifest = maniread("$distdir/MANIFEST");
281 # VMS is non-case preserving, so we can't know what the MANIFEST will
283 _normalize($manifest);
284 is( $manifest->{'meta.yml'}, 'Module meta-data (added by MakeMaker)' );
287 # Test NO_META META.yml suppression
289 ok( !-f $meta_yml, 'META.yml deleted' );
290 @mpl_out = run(qq{$perl Makefile.PL "NO_META=1"});
291 cmp_ok( $?, '==', 0, 'Makefile.PL exited with zero' ) || diag(@mpl_out);
292 my $distdir_out = run("$make distdir");
293 is( $?, 0, 'distdir' ) || diag($distdir_out);
294 ok( !-f $meta_yml, 'META.yml generation suppressed by NO_META' );
297 # Make sure init_dirscan doesn't go into the distdir
298 @mpl_out = run(qq{$perl Makefile.PL "PREFIX=../dummy-install"});
300 cmp_ok( $?, '==', 0, 'Makefile.PL exited with zero' ) || diag(@mpl_out);
302 ok( grep(/^Writing $makefile for Big::Dummy/, @mpl_out) == 1,
303 'init_dirscan skipped distdir') ||
306 # I know we'll get ignored errors from make here, that's ok.
307 # Send STDERR off to oblivion.
308 open(SAVERR, ">&STDERR") or die $!;
309 open(STDERR, ">",File::Spec->devnull) or die $!;
311 my $realclean_out = run("$make realclean");
312 is( $?, 0, 'realclean' ) || diag($realclean_out);
314 open(STDERR, ">&SAVERR") or die $!;
321 while(my($k,$v) = each %$hash) {