use strict;
use Config;
-use Test::More tests => 48;
+use Test::More tests => 80;
use MakeMaker::Test::Utils;
+use MakeMaker::Test::Setup::BFD;
use File::Find;
use File::Spec;
+use File::Path;
# 'make disttest' sets a bunch of environment variables which interfere
# with our testing.
my $perl = which_perl();
my $Is_VMS = $^O eq 'VMS';
-my $root_dir = 't';
-
-if( $^O eq 'VMS' ) {
- # On older systems we might exceed the 8-level directory depth limit
- # imposed by RMS. We get around this with a rooted logical, but we
- # can't create logical names with attributes in Perl, so we do it
- # in a DCL subprocess and put it in the job table so the parent sees it.
- open( BFDTMP, '>bfdtesttmp.com' ) || die "Error creating command file; $!";
- print BFDTMP <<'COMMAND';
-$ IF F$TRNLNM("PERL_CORE") .EQS. "" .AND. F$TYPE(PERL_CORE) .EQS. ""
-$ THEN
-$! building CPAN version
-$ BFD_TEST_ROOT = F$PARSE("SYS$DISK:[]",,,,"NO_CONCEAL")-".][000000"-"]["-"].;"+".]"
-$ ELSE
-$! we're in the core
-$ BFD_TEST_ROOT = F$PARSE("SYS$DISK:[-]",,,,"NO_CONCEAL")-".][000000"-"]["-"].;"+".]"
-$ ENDIF
-$ DEFINE/JOB/NOLOG/TRANSLATION=CONCEALED BFD_TEST_ROOT 'BFD_TEST_ROOT'
-COMMAND
- close BFDTMP;
-
- system '@bfdtesttmp.com';
- END { 1 while unlink 'bfdtesttmp.com' }
- $root_dir = 'BFD_TEST_ROOT:[t]';
-}
-
-chdir $root_dir;
+# GNV logical interferes with testing
+$ENV{'bin'} = '[.bin]' if $Is_VMS;
+chdir 't';
perl_lib;
$| = 1;
-ok( chdir 'Big-Dummy', "chdir'd to Big-Dummy" ) ||
+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"});
+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);
' <DEPENDENCY>' );
like( $ppd_html, qr{^\s*<OS NAME="$Config{osname}" />}m,
' <OS>' );
-like( $ppd_html, qr{^\s*<ARCHITECTURE NAME="$Config{archname}" />}m,
+my $archname = $Config{archname};
+$archname .= "-". substr($Config{version},0,3) if $] >= 5.008;
+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>');
my $test_out = run("$make test");
like( $test_out, qr/All tests successful/, 'make test' );
-is( $?, 0, ' exited normally' );
+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' );
+is( $?, 0, ' exited normally' ) ||
+ diag $test_out;
my $install_out = run("$make install");
like( $install_out, qr/^Installing /m );
like( $install_out, qr/^Writing /m );
-ok( -r 'dummy-install', ' install dir created' );
+ok( -r '../dummy-install', ' install dir created' );
my %files = ();
find( sub {
# do it case-insensitive for non-case preserving OSs
- $files{lc $_} = $File::Find::name;
-}, 'dummy-install' );
+ 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;
+ skip 'VMS install targets do not preserve $(PREFIX)', 9 if $Is_VMS;
$install_out = run("$make install PREFIX=elsewhere");
is( $?, 0, 'install with PREFIX override' ) || diag $install_out;
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)', 11 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 );
+ like( $install_out, qr/^Writing /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)', 10 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 );
+ like( $install_out, qr/^Writing /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');
}
# Test META.yml generation
use ExtUtils::Manifest qw(maniread);
-ok( -f 'META.yml', 'META.yml written' );
-my $manifest = maniread();
+
+my $distdir = 'Big-Dummy-0.01';
+$distdir =~ s/\./_/g if $Is_VMS;
+my $meta_yml = "$distdir/META.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' );
+
+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 in YAML' );
+is( $manifest->{'meta.yml'}, 'Module meta-data (added by MakeMaker)' );
+
+
+# Test NO_META META.yml suppression
+unlink $meta_yml;
+ok( !-f $meta_yml, 'META.yml deleted' );
+@mpl_out = run(qq{$perl Makefile.PL "NO_META=1"});
+cmp_ok( $?, '==', 0, 'Makefile.PL exited with zero' ) || diag(@mpl_out);
+my $distdir_out = run("$make distdir");
+is( $?, 0, 'distdir' ) || diag($distdir_out);
+ok( !-f $meta_yml, 'META.yml generation suppressed by NO_META' );
# Make sure init_dirscan doesn't go into the distdir
-@mpl_out = run(qq{$perl Makefile.PL "PREFIX=dummy-install"});
+@mpl_out = run(qq{$perl Makefile.PL "PREFIX=../dummy-install"});
-cmp_ok( $?, '==', 0, 'Makefile.PL exited with zero' ) ||
- diag(@mpl_out);
+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') ||