1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380
|
#!/usr/bin/perl -w
# This test puts MakeMaker through the paces of a basic perl module
# build, test and installation of the Big::Fat::Dummy module.
BEGIN {
unshift @INC, 't/lib';
}
use strict;
use Config;
use ExtUtils::MakeMaker;
use Test::More tests => 98;
use MakeMaker::Test::Utils;
use MakeMaker::Test::Setup::BFD;
use File::Find;
use File::Spec;
use File::Path;
my $perl = which_perl();
my $Is_VMS = $^O eq 'VMS';
chdir 't';
perl_lib;
my $Touch_Time = calibrate_mtime();
$| = 1;
ok( setup_recurs(), 'setup' );
END {
ok( chdir File::Spec->updir );
ok( teardown_recurs(), 'teardown' );
}
ok( chdir('Big-Dummy'), "chdir'd to Big-Dummy" ) ||
diag("chdir failed: $!");
my @mpl_out = run(qq{$perl Makefile.PL "PREFIX=../dummy-install"});
END { rmtree '../dummy-install'; }
cmp_ok( $?, '==', 0, 'Makefile.PL exited with zero' ) ||
diag(@mpl_out);
my $makefile = makefile_name();
ok( grep(/^Writing $makefile for Big::Dummy/,
@mpl_out) == 1,
'Makefile.PL output looks right');
ok( grep(/^Current package is: main$/,
@mpl_out) == 1,
'Makefile.PL run in package main');
ok( -e $makefile, 'Makefile exists' );
# -M is flakey on VMS
my $mtime = (stat($makefile))[9];
cmp_ok( $Touch_Time, '<=', $mtime, ' its been touched' );
END { unlink makefile_name(), makefile_backup() }
my $make = make_run();
{
# Supress 'make manifest' noise
local $ENV{PERL_MM_MANIFEST_VERBOSE} = 0;
my $manifest_out = run("$make manifest");
ok( -e 'MANIFEST', 'make manifest created a MANIFEST' );
ok( -s 'MANIFEST', ' its not empty' );
}
END { unlink 'MANIFEST'; }
my $ppd_out = run("$make ppd");
is( $?, 0, ' exited normally' ) || diag $ppd_out;
ok( open(PPD, 'Big-Dummy.ppd'), ' .ppd file generated' );
my $ppd_html;
{ local $/; $ppd_html = <PPD> }
close PPD;
like( $ppd_html, qr{^<SOFTPKG NAME="Big-Dummy" VERSION="0.01">}m,
' <SOFTPKG>' );
like( $ppd_html, qr{^\s*<ABSTRACT>Try "our" hot dog's</ABSTRACT>}m,
' <ABSTRACT>');
like( $ppd_html,
qr{^\s*<AUTHOR>Michael G Schwern <schwern\@pobox.com></AUTHOR>}m,
' <AUTHOR>' );
like( $ppd_html, qr{^\s*<IMPLEMENTATION>}m, ' <IMPLEMENTATION>');
like( $ppd_html, qr{^\s*<REQUIRE NAME="strict::" />}m, ' <REQUIRE>' );
unlike( $ppd_html, qr{^\s*<REQUIRE NAME="warnings::" />}m, 'no <REQUIRE> for build_require' );
my $archname = $Config{archname};
if( $] >= 5.008 ) {
# XXX This is a copy of the internal logic, so it's not a great test
$archname .= "-$Config{PERL_REVISION}.$Config{PERL_VERSION}";
}
like( $ppd_html, qr{^\s*<ARCHITECTURE NAME="$archname" />}m,
' <ARCHITECTURE>');
like( $ppd_html, qr{^\s*<CODEBASE HREF="" />}m, ' <CODEBASE>');
like( $ppd_html, qr{^\s*</IMPLEMENTATION>}m, ' </IMPLEMENTATION>');
like( $ppd_html, qr{^\s*</SOFTPKG>}m, ' </SOFTPKG>');
END { unlink 'Big-Dummy.ppd' }
my $test_out = run("$make test");
like( $test_out, qr/All tests successful/, 'make test' );
is( $?, 0, ' exited normally' ) ||
diag $test_out;
# Test 'make test TEST_VERBOSE=1'
my $make_test_verbose = make_macro($make, 'test', TEST_VERBOSE => 1);
$test_out = run("$make_test_verbose");
like( $test_out, qr/ok \d+ - TEST_VERBOSE/, 'TEST_VERBOSE' );
like( $test_out, qr/All tests successful/, ' successful' );
is( $?, 0, ' exited normally' ) ||
diag $test_out;
my $install_out = run("$make install");
is( $?, 0, 'install' ) || diag $install_out;
like( $install_out, qr/^Installing /m );
ok( -r '../dummy-install', ' install dir created' );
my %files = ();
find( sub {
# do it case-insensitive for non-case preserving OSs
my $file = lc $_;
# VMS likes to put dots on the end of things that don't have them.
$file =~ s/\.$// if $Is_VMS;
$files{$file} = $File::Find::name;
}, '../dummy-install' );
ok( $files{'dummy.pm'}, ' Dummy.pm installed' );
ok( $files{'liar.pm'}, ' Liar.pm installed' );
ok( $files{'program'}, ' program installed' );
ok( $files{'.packlist'}, ' packlist created' );
ok( $files{'perllocal.pod'},' perllocal.pod created' );
SKIP: {
skip 'VMS install targets do not preserve $(PREFIX)', 8 if $Is_VMS;
$install_out = run("$make install PREFIX=elsewhere");
is( $?, 0, 'install with PREFIX override' ) || diag $install_out;
like( $install_out, qr/^Installing /m );
ok( -r 'elsewhere', ' install dir created' );
%files = ();
find( sub { $files{$_} = $File::Find::name; }, 'elsewhere' );
ok( $files{'Dummy.pm'}, ' Dummy.pm installed' );
ok( $files{'Liar.pm'}, ' Liar.pm installed' );
ok( $files{'program'}, ' program installed' );
ok( $files{'.packlist'}, ' packlist created' );
ok( $files{'perllocal.pod'},' perllocal.pod created' );
rmtree('elsewhere');
}
SKIP: {
skip 'VMS install targets do not preserve $(DESTDIR)', 10 if $Is_VMS;
$install_out = run("$make install PREFIX= DESTDIR=other");
is( $?, 0, 'install with DESTDIR' ) ||
diag $install_out;
like( $install_out, qr/^Installing /m );
ok( -d 'other', ' destdir created' );
%files = ();
my $perllocal;
find( sub {
$files{$_} = $File::Find::name;
}, 'other' );
ok( $files{'Dummy.pm'}, ' Dummy.pm installed' );
ok( $files{'Liar.pm'}, ' Liar.pm installed' );
ok( $files{'program'}, ' program installed' );
ok( $files{'.packlist'}, ' packlist created' );
ok( $files{'perllocal.pod'},' perllocal.pod created' );
ok( open(PERLLOCAL, $files{'perllocal.pod'} ) ) ||
diag("Can't open $files{'perllocal.pod'}: $!");
{ local $/;
unlike(<PERLLOCAL>, qr/other/, 'DESTDIR should not appear in perllocal');
}
close PERLLOCAL;
# TODO not available in the min version of Test::Harness we require
# ok( open(PACKLIST, $files{'.packlist'} ) ) ||
# diag("Can't open $files{'.packlist'}: $!");
# { local $/;
# local $TODO = 'DESTDIR still in .packlist';
# unlike(<PACKLIST>, qr/other/, 'DESTDIR should not appear in .packlist');
# }
# close PACKLIST;
rmtree('other');
}
SKIP: {
skip 'VMS install targets do not preserve $(PREFIX)', 9 if $Is_VMS;
$install_out = run("$make install PREFIX=elsewhere DESTDIR=other/");
is( $?, 0, 'install with PREFIX override and DESTDIR' ) ||
diag $install_out;
like( $install_out, qr/^Installing /m );
ok( !-d 'elsewhere', ' install dir not created' );
ok( -d 'other/elsewhere', ' destdir created' );
%files = ();
find( sub { $files{$_} = $File::Find::name; }, 'other/elsewhere' );
ok( $files{'Dummy.pm'}, ' Dummy.pm installed' );
ok( $files{'Liar.pm'}, ' Liar.pm installed' );
ok( $files{'program'}, ' program installed' );
ok( $files{'.packlist'}, ' packlist created' );
ok( $files{'perllocal.pod'},' perllocal.pod created' );
rmtree('other');
}
my $dist_test_out = run("$make disttest");
is( $?, 0, 'disttest' ) || diag($dist_test_out);
# Test META.yml generation
use ExtUtils::Manifest qw(maniread);
my $distdir = 'Big-Dummy-0.01';
$distdir =~ s/\./_/g if $Is_VMS;
my $meta_yml = "$distdir/META.yml";
my $mymeta_yml = "$distdir/MYMETA.yml";
ok( !-f 'META.yml', 'META.yml not written to source dir' );
ok( -f $meta_yml, 'META.yml written to dist dir' );
ok( !-e "META_new.yml", 'temp META.yml file not left around' );
ok( -f 'MYMETA.yml', 'MYMETA.yml is written to source dir' );
ok( -f $mymeta_yml, 'MYMETA.yml is written to dist dir on disttest' );
SKIP: {
# META.yml spec 1.4 was added in 0.11
skip "Test::YAML::Meta >= 0.11 required", 4
unless eval { require Test::YAML::Meta } and
Test::YAML::Meta->VERSION >= 0.11;
Test::YAML::Meta::meta_spec_ok($meta_yml);
Test::YAML::Meta::meta_spec_ok($mymeta_yml);
}
ok open META, $meta_yml or diag $!;
my $meta = join '', <META>;
ok close META;
is $meta, <<"END";
--- #YAML:1.0
name: Big-Dummy
version: 0.01
abstract: Try "our" hot dog's
author:
- Michael G Schwern <schwern\@pobox.com>
license: unknown
distribution_type: module
configure_requires:
ExtUtils::MakeMaker: 0
build_requires:
warnings: 0
requires:
strict: 0
no_index:
directory:
- t
- inc
generated_by: ExtUtils::MakeMaker version $ExtUtils::MakeMaker::VERSION
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
version: 1.4
END
my $mymeta_expected_content=<<"END";
---
abstract: "Try \\"our\\" hot dog's"
author:
- 'Michael G Schwern <schwern\@pobox.com>'
build_requires:
warnings: 0
configure_requires:
ExtUtils::MakeMaker: 0
distribution_type: module
dynamic_config: 0
generated_by: 'ExtUtils::MakeMaker version $ExtUtils::MakeMaker::VERSION'
license: unknown
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
version: 1.4
name: Big-Dummy
no_index:
directory:
- t
- inc
requires:
strict: 0
version: 0.01
END
{
ok open META, $mymeta_yml or diag $!;
my $mymeta_content = join '', <META>;
ok close META;
is($mymeta_content,$mymeta_expected_content,"MYMETA.yml (using Parse::CPAN::Meta) content is correct");
}
{
ok open META, 'MYMETA.yml' or diag $!;
my $mymeta_content = join '', <META>;
ok close META;
is($mymeta_content,$mymeta_expected_content,"MYMETA.yml (generated from scratch)content is correct");
}
my $manifest = maniread("$distdir/MANIFEST");
# VMS is non-case preserving, so we can't know what the MANIFEST will
# look like. :(
_normalize($manifest);
is( $manifest->{'meta.yml'}, 'Module meta-data (added by MakeMaker)' );
# Test NO_META META.yml suppression
unlink $meta_yml;
unlink 'MYMETA.yml';
ok( !-f $meta_yml, 'META.yml deleted' );
ok( !-f 'MYMETA.yml','MYMETA.yml deleted' );
@mpl_out = run(qq{$perl Makefile.PL "NO_META=1"});
ok( -f 'MYMETA.yml', 'MYMETA.yml generation not suppressed by NO_META' );
cmp_ok( $?, '==', 0, 'Makefile.PL exited with zero' ) || diag(@mpl_out);
ok( !-f $meta_yml, 'META.yml generation suppressed by NO_META' );
my $distdir_out = run("$make distdir");
is( $?, 0, 'distdir' ) || diag($distdir_out);
ok( !-f $meta_yml, 'META.yml generation suppressed by NO_META' );
unlink 'MYMETA.yml';
ok( !-f 'MYMETA.yml','MYMETA.yml deleted' );
@mpl_out = run(qq{$perl Makefile.PL "NO_MYMETA=1"});
cmp_ok( $?, '==', 0, 'Makefile.PL exited with zero' ) || diag(@mpl_out);
$distdir_out = run("$make distdir");
is( $?, 0, 'distdir' ) || diag($distdir_out);
ok( !-f 'MYMETA.yml','MYMETA.yml generation suppressed by NO_MYMETA' );
ok( -f $meta_yml, 'META.yml generation not suppressed by NO_MYMETA' );
# Make sure init_dirscan doesn't go into the distdir
@mpl_out = run(qq{$perl Makefile.PL "PREFIX=../dummy-install"});
cmp_ok( $?, '==', 0, 'Makefile.PL exited with zero' ) || diag(@mpl_out);
ok( grep(/^Writing $makefile for Big::Dummy/, @mpl_out) == 1,
'init_dirscan skipped distdir') ||
diag(@mpl_out);
# I know we'll get ignored errors from make here, that's ok.
# Send STDERR off to oblivion.
open(SAVERR, ">&STDERR") or die $!;
open(STDERR, ">",File::Spec->devnull) or die $!;
my $realclean_out = run("$make realclean");
is( $?, 0, 'realclean' ) || diag($realclean_out);
open(STDERR, ">&SAVERR") or die $!;
close SAVERR;
sub _normalize {
my $hash = shift;
while(my($k,$v) = each %$hash) {
delete $hash->{$k};
$hash->{lc $k} = $v;
}
}
|