1N/A#!/usr/bin/perl -w
1N/A
1N/A# This test puts MakeMaker through the paces of a basic perl module
1N/A# build, test and installation of the Big::Fat::Dummy module.
1N/A
1N/ABEGIN {
1N/A if( $ENV{PERL_CORE} ) {
1N/A chdir 't' if -d 't';
1N/A @INC = ('../lib', 'lib');
1N/A }
1N/A else {
1N/A unshift @INC, 't/lib';
1N/A }
1N/A}
1N/A
1N/Ause strict;
1N/Ause Config;
1N/A
1N/Ause Test::More tests => 73;
1N/Ause MakeMaker::Test::Utils;
1N/Ause File::Find;
1N/Ause File::Spec;
1N/Ause File::Path;
1N/A
1N/A# 'make disttest' sets a bunch of environment variables which interfere
1N/A# with our testing.
1N/Adelete @ENV{qw(PREFIX LIB MAKEFLAGS)};
1N/A
1N/Amy $perl = which_perl();
1N/Amy $Is_VMS = $^O eq 'VMS';
1N/A
1N/Achdir($Is_VMS ? 'BFD_TEST_ROOT:[t]' : 't');
1N/A
1N/A
1N/Aperl_lib;
1N/A
1N/Amy $Touch_Time = calibrate_mtime();
1N/A
1N/A$| = 1;
1N/A
1N/Aok( chdir('Big-Dummy'), "chdir'd to Big-Dummy" ) ||
1N/A diag("chdir failed: $!");
1N/A
1N/Amy @mpl_out = run(qq{$perl Makefile.PL "PREFIX=../dummy-install"});
1N/AEND { rmtree '../dummy-install'; }
1N/A
1N/Acmp_ok( $?, '==', 0, 'Makefile.PL exited with zero' ) ||
1N/A diag(@mpl_out);
1N/A
1N/Amy $makefile = makefile_name();
1N/Aok( grep(/^Writing $makefile for Big::Dummy/,
1N/A @mpl_out) == 1,
1N/A 'Makefile.PL output looks right');
1N/A
1N/Aok( grep(/^Current package is: main$/,
1N/A @mpl_out) == 1,
1N/A 'Makefile.PL run in package main');
1N/A
1N/Aok( -e $makefile, 'Makefile exists' );
1N/A
1N/A# -M is flakey on VMS
1N/Amy $mtime = (stat($makefile))[9];
1N/Acmp_ok( $Touch_Time, '<=', $mtime, ' its been touched' );
1N/A
1N/AEND { unlink makefile_name(), makefile_backup() }
1N/A
1N/Amy $make = make_run();
1N/A
1N/A{
1N/A # Supress 'make manifest' noise
1N/A local $ENV{PERL_MM_MANIFEST_VERBOSE} = 0;
1N/A my $manifest_out = run("$make manifest");
1N/A ok( -e 'MANIFEST', 'make manifest created a MANIFEST' );
1N/A ok( -s 'MANIFEST', ' its not empty' );
1N/A}
1N/A
1N/AEND { unlink 'MANIFEST'; }
1N/A
1N/A
1N/Amy $ppd_out = run("$make ppd");
1N/Ais( $?, 0, ' exited normally' ) || diag $ppd_out;
1N/Aok( open(PPD, 'Big-Dummy.ppd'), ' .ppd file generated' );
1N/Amy $ppd_html;
1N/A{ local $/; $ppd_html = <PPD> }
1N/Aclose PPD;
1N/Alike( $ppd_html, qr{^<SOFTPKG NAME="Big-Dummy" VERSION="0,01,0,0">}m,
1N/A ' <SOFTPKG>' );
1N/Alike( $ppd_html, qr{^\s*<TITLE>Big-Dummy</TITLE>}m, ' <TITLE>' );
1N/Alike( $ppd_html, qr{^\s*<ABSTRACT>Try "our" hot dog's</ABSTRACT>}m,
1N/A ' <ABSTRACT>');
1N/Alike( $ppd_html,
1N/A qr{^\s*<AUTHOR>Michael G Schwern &lt;schwern\@pobox.com&gt;</AUTHOR>}m,
1N/A ' <AUTHOR>' );
1N/Alike( $ppd_html, qr{^\s*<IMPLEMENTATION>}m, ' <IMPLEMENTATION>');
1N/Alike( $ppd_html, qr{^\s*<DEPENDENCY NAME="strict" VERSION="0,0,0,0" />}m,
1N/A ' <DEPENDENCY>' );
1N/Alike( $ppd_html, qr{^\s*<OS NAME="$Config{osname}" />}m,
1N/A ' <OS>' );
1N/Alike( $ppd_html, qr{^\s*<ARCHITECTURE NAME="$Config{archname}" />}m,
1N/A ' <ARCHITECTURE>');
1N/Alike( $ppd_html, qr{^\s*<CODEBASE HREF="" />}m, ' <CODEBASE>');
1N/Alike( $ppd_html, qr{^\s*</IMPLEMENTATION>}m, ' </IMPLEMENTATION>');
1N/Alike( $ppd_html, qr{^\s*</SOFTPKG>}m, ' </SOFTPKG>');
1N/AEND { unlink 'Big-Dummy.ppd' }
1N/A
1N/A
1N/Amy $test_out = run("$make test");
1N/Alike( $test_out, qr/All tests successful/, 'make test' );
1N/Ais( $?, 0, ' exited normally' ) ||
1N/A diag $test_out;
1N/A
1N/A# Test 'make test TEST_VERBOSE=1'
1N/Amy $make_test_verbose = make_macro($make, 'test', TEST_VERBOSE => 1);
1N/A$test_out = run("$make_test_verbose");
1N/Alike( $test_out, qr/ok \d+ - TEST_VERBOSE/, 'TEST_VERBOSE' );
1N/Alike( $test_out, qr/All tests successful/, ' successful' );
1N/Ais( $?, 0, ' exited normally' ) ||
1N/A diag $test_out;
1N/A
1N/A
1N/Amy $install_out = run("$make install");
1N/Ais( $?, 0, 'install' ) || diag $install_out;
1N/Alike( $install_out, qr/^Installing /m );
1N/Alike( $install_out, qr/^Writing /m );
1N/A
1N/Aok( -r '../dummy-install', ' install dir created' );
1N/Amy %files = ();
1N/Afind( sub {
1N/A # do it case-insensitive for non-case preserving OSs
1N/A $files{lc $_} = $File::Find::name;
1N/A}, '../dummy-install' );
1N/Aok( $files{'dummy.pm'}, ' Dummy.pm installed' );
1N/Aok( $files{'liar.pm'}, ' Liar.pm installed' );
1N/Aok( $files{'.packlist'}, ' packlist created' );
1N/Aok( $files{'perllocal.pod'},' perllocal.pod created' );
1N/A
1N/A
1N/ASKIP: {
1N/A skip "VMS install targets do not preserve $(PREFIX)", 8 if $Is_VMS;
1N/A
1N/A $install_out = run("$make install PREFIX=elsewhere");
1N/A is( $?, 0, 'install with PREFIX override' ) || diag $install_out;
1N/A like( $install_out, qr/^Installing /m );
1N/A like( $install_out, qr/^Writing /m );
1N/A
1N/A ok( -r 'elsewhere', ' install dir created' );
1N/A %files = ();
1N/A find( sub { $files{$_} = $File::Find::name; }, 'elsewhere' );
1N/A ok( $files{'Dummy.pm'}, ' Dummy.pm installed' );
1N/A ok( $files{'Liar.pm'}, ' Liar.pm installed' );
1N/A ok( $files{'.packlist'}, ' packlist created' );
1N/A ok( $files{'perllocal.pod'},' perllocal.pod created' );
1N/A rmtree('elsewhere');
1N/A}
1N/A
1N/A
1N/ASKIP: {
1N/A skip "VMS install targets do not preserve $(DESTDIR)", 10 if $Is_VMS;
1N/A
1N/A $install_out = run("$make install PREFIX= DESTDIR=other");
1N/A is( $?, 0, 'install with DESTDIR' ) ||
1N/A diag $install_out;
1N/A like( $install_out, qr/^Installing /m );
1N/A like( $install_out, qr/^Writing /m );
1N/A
1N/A ok( -d 'other', ' destdir created' );
1N/A %files = ();
1N/A my $perllocal;
1N/A find( sub {
1N/A $files{$_} = $File::Find::name;
1N/A }, 'other' );
1N/A ok( $files{'Dummy.pm'}, ' Dummy.pm installed' );
1N/A ok( $files{'Liar.pm'}, ' Liar.pm installed' );
1N/A ok( $files{'.packlist'}, ' packlist created' );
1N/A ok( $files{'perllocal.pod'},' perllocal.pod created' );
1N/A
1N/A ok( open(PERLLOCAL, $files{'perllocal.pod'} ) ) ||
1N/A diag("Can't open $files{'perllocal.pod'}: $!");
1N/A { local $/;
1N/A unlike(<PERLLOCAL>, qr/other/, 'DESTDIR should not appear in perllocal');
1N/A }
1N/A close PERLLOCAL;
1N/A
1N/A# TODO not available in the min version of Test::Harness we require
1N/A# ok( open(PACKLIST, $files{'.packlist'} ) ) ||
1N/A# diag("Can't open $files{'.packlist'}: $!");
1N/A# { local $/;
1N/A# local $TODO = 'DESTDIR still in .packlist';
1N/A# unlike(<PACKLIST>, qr/other/, 'DESTDIR should not appear in .packlist');
1N/A# }
1N/A# close PACKLIST;
1N/A
1N/A rmtree('other');
1N/A}
1N/A
1N/A
1N/ASKIP: {
1N/A skip "VMS install targets do not preserve $(PREFIX)", 9 if $Is_VMS;
1N/A
1N/A $install_out = run("$make install PREFIX=elsewhere DESTDIR=other/");
1N/A is( $?, 0, 'install with PREFIX override and DESTDIR' ) ||
1N/A diag $install_out;
1N/A like( $install_out, qr/^Installing /m );
1N/A like( $install_out, qr/^Writing /m );
1N/A
1N/A ok( !-d 'elsewhere', ' install dir not created' );
1N/A ok( -d 'other/elsewhere', ' destdir created' );
1N/A %files = ();
1N/A find( sub { $files{$_} = $File::Find::name; }, 'other/elsewhere' );
1N/A ok( $files{'Dummy.pm'}, ' Dummy.pm installed' );
1N/A ok( $files{'Liar.pm'}, ' Liar.pm installed' );
1N/A ok( $files{'.packlist'}, ' packlist created' );
1N/A ok( $files{'perllocal.pod'},' perllocal.pod created' );
1N/A rmtree('other');
1N/A}
1N/A
1N/A
1N/Amy $dist_test_out = run("$make disttest");
1N/Ais( $?, 0, 'disttest' ) || diag($dist_test_out);
1N/A
1N/A# Test META.yml generation
1N/Ause ExtUtils::Manifest qw(maniread);
1N/Aok( -f 'META.yml', 'META.yml written' );
1N/Amy $manifest = maniread();
1N/A# VMS is non-case preserving, so we can't know what the MANIFEST will
1N/A# look like. :(
1N/A_normalize($manifest);
1N/Ais( $manifest->{'meta.yml'}, 'Module meta-data (added by MakeMaker)' );
1N/A
1N/A# Test NO_META META.yml suppression
1N/Aunlink 'META.yml';
1N/Aok( !-f 'META.yml', 'META.yml deleted' );
1N/A@mpl_out = run(qq{$perl Makefile.PL "NO_META=1"});
1N/Acmp_ok( $?, '==', 0, 'Makefile.PL exited with zero' ) || diag(@mpl_out);
1N/Amy $metafile_out = run("$make metafile");
1N/Ais( $?, 0, 'metafile' ) || diag($metafile_out);
1N/Aok( !-f 'META.yml', 'META.yml generation suppressed by NO_META' );
1N/A
1N/A# Test if MANIFEST is read-only.
1N/Achmod 0444, 'MANIFEST';
1N/A@mpl_out = run(qq{$perl Makefile.PL});
1N/Acmp_ok( $?, '==', 0, 'Makefile.PL exited with zero' ) || diag(@mpl_out);
1N/A$metafile_out = run("$make metafile_addtomanifest");
1N/Ais( $?, 0, q{metafile_addtomanifest didn't die with locked MANIFEST} ) ||
1N/A diag($metafile_out);
1N/A
1N/A
1N/A# Make sure init_dirscan doesn't go into the distdir
1N/A@mpl_out = run(qq{$perl Makefile.PL "PREFIX=../dummy-install"});
1N/A
1N/Acmp_ok( $?, '==', 0, 'Makefile.PL exited with zero' ) || diag(@mpl_out);
1N/A
1N/Aok( grep(/^Writing $makefile for Big::Dummy/, @mpl_out) == 1,
1N/A 'init_dirscan skipped distdir') ||
1N/A diag(@mpl_out);
1N/A
1N/A# I know we'll get ignored errors from make here, that's ok.
1N/A# Send STDERR off to oblivion.
1N/Aopen(SAVERR, ">&STDERR") or die $!;
1N/Aopen(STDERR, ">".File::Spec->devnull) or die $!;
1N/A
1N/Amy $realclean_out = run("$make realclean");
1N/Ais( $?, 0, 'realclean' ) || diag($realclean_out);
1N/A
1N/Aopen(STDERR, ">&SAVERR") or die $!;
1N/Aclose SAVERR;
1N/A
1N/A
1N/Asub _normalize {
1N/A my $hash = shift;
1N/A
1N/A while(my($k,$v) = each %$hash) {
1N/A delete $hash->{$k};
1N/A $hash->{lc $k} = $v;
1N/A }
1N/A}