From: Nicholas Clark Date: Mon, 23 Feb 2009 14:15:49 +0000 (+0000) Subject: Update to Module::Build 0.31_04 (with a tweak to MBTest.pm) X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=66e531b6b23122113bed8498baac1ef25a958d57;p=p5sagit%2Fp5-mst-13.2.git Update to Module::Build 0.31_04 (with a tweak to MBTest.pm) --- diff --git a/MANIFEST b/MANIFEST index ca5213f..cd3fd06 100644 --- a/MANIFEST +++ b/MANIFEST @@ -2429,6 +2429,7 @@ lib/Module/Build/scripts/config_data Module::Build lib/Module/Build/t/add_property.t Module::Build lib/Module/Build/t/basic.t Module::Build lib/Module/Build/t/bundled/Tie/CPHash.pm Module::Build.pm +lib/Module/Build/t/compat/exit.t Module::Build lib/Module/Build/t/compat.t Module::Build lib/Module/Build/t/destinations.t Module::Build lib/Module/Build/t/extend.t Module::Build diff --git a/lib/Module/Build.pm b/lib/Module/Build.pm index 8ff3eab..0dc1a88 100644 --- a/lib/Module/Build.pm +++ b/lib/Module/Build.pm @@ -15,7 +15,7 @@ use Module::Build::Base; use vars qw($VERSION @ISA); @ISA = qw(Module::Build::Base); -$VERSION = '0.31012'; +$VERSION = '0.31_04'; $VERSION = eval $VERSION; # Okay, this is the brute-force method of finding out what kind of @@ -161,11 +161,11 @@ This illustrates initial configuration and the running of three 'actions'. In this case the actions run are 'build' (the default action), 'test', and 'install'. Other actions defined so far include: - build manifest - clean manpages - code pardist - config_data ppd - diff ppmdist + build manpages + clean pardist + code ppd + config_data ppmdist + diff prereq_data dist prereq_report distcheck pure_install distclean realclean @@ -178,6 +178,7 @@ action), 'test', and 'install'. Other actions defined so far include: help testpod html testpodcoverage install versioninstall + manifest You can run the 'help' action for a complete list of actions. @@ -513,6 +514,14 @@ This uses the same mechanism as the C action to tar & zip its output, so you can supply C and/or C parameters to affect the result. +=item prereq_data + +[version 0.32] + +This action prints out a Perl data structure of all prerequsites and the versions +required. The output can be loaded again using C. This can be useful for +external tools that wish to query a Build script for prerequisites. + =item prereq_report [version 0.28] diff --git a/lib/Module/Build/API.pod b/lib/Module/Build/API.pod index dee3de5..83e93f5 100644 --- a/lib/Module/Build/API.pod +++ b/lib/Module/Build/API.pod @@ -1548,6 +1548,18 @@ Examples: } } +=item prereq_data() + +[version 0.32] + +Returns a reference to a hash describing all prerequisites. The keys of the +hash will the various prerequisite types ('requires', 'build_requires', +'configure_requires', 'recommends', or 'conflicts') and the values will +references to hashes of module names and version numbers. Only prerequisites +types that are defined will be included. The C action is just a +thin wrapper around the C method and dumps the hash as a string +that can be loaded using C. + =item prereq_report() [version 0.28] diff --git a/lib/Module/Build/Base.pm b/lib/Module/Build/Base.pm index 95dfbbd..71eb214 100644 --- a/lib/Module/Build/Base.pm +++ b/lib/Module/Build/Base.pm @@ -4,7 +4,7 @@ package Module::Build::Base; use strict; use vars qw($VERSION); -$VERSION = '0.31012'; +$VERSION = '0.31_04'; $VERSION = eval $VERSION; BEGIN { require 5.00503 } @@ -1188,7 +1188,7 @@ sub check_autofeatures { } } - $self->log_warn("\n"); + $self->log_warn("\n") unless $self->quiet; } sub prereq_failures { @@ -2054,15 +2054,25 @@ sub ACTION_prereq_report { $self->log_info( $self->prereq_report ); } -sub prereq_report { +sub ACTION_prereq_data { + my $self = shift; + $self->log_info( Module::Build::Dumper->_data_dump( $self->prereq_data ) ); +} + +sub prereq_data { my $self = shift; my @types = @{ $self->prereq_action_types }; - my $info = { map { $_ => $self->$_() } @types }; + my $info = { map { $_ => $self->$_() } grep { %{$self->$_()} } @types }; + return $info; +} + +sub prereq_report { + my $self = shift; + my $info = $self->prereq_data; my $output = ''; - foreach my $type (@types) { + foreach my $type (keys %$info) { my $prereqs = $info->{$type}; - next unless %$prereqs; $output .= "\n$type:\n"; my $mod_len = 2; my $ver_len = 4; @@ -2949,6 +2959,14 @@ sub ACTION_install { sub ACTION_fakeinstall { my ($self) = @_; require ExtUtils::Install; + my $eui_version = ExtUtils::Install->VERSION; + if ( $eui_version < 1.32 ) { + $self->log_warn( + "The 'fakeinstall' action requires Extutils::Install 1.32 or later.\n" + . "(You only have version $eui_version)." + ); + return; + } $self->depends_on('build'); ExtUtils::Install::install($self->install_map, !$self->quiet, 1, $self->{args}{uninst}||0); } @@ -3966,8 +3984,6 @@ sub _prefixify { return $self->_prefixify_default( $type, $rprefix ); } elsif( !File::Spec->file_name_is_absolute($path) ) { $self->log_verbose(" path is relative, not prefixifying.\n"); - } elsif( $sprefix eq $rprefix ) { - $self->log_verbose(" no new prefix.\n"); } elsif( $path !~ s{^\Q$sprefix\E\b}{}s ) { $self->log_verbose(" cannot prefixify, falling back to default.\n"); return $self->_prefixify_default( $type, $rprefix ); @@ -4400,12 +4416,15 @@ sub copy_if_modified { ); $args{verbose} = !$self->quiet unless exists $args{verbose}; - + my $file = $args{from}; unless (defined $file and length $file) { die "No 'from' parameter given to copy_if_modified"; } - + + # makes no sense to replicate an absolute path, so assume flatten + $args{flatten} = 1 if File::Spec->file_name_is_absolute( $file ); + my $to_path; if (defined $args{to} and length $args{to}) { $to_path = $args{to}; diff --git a/lib/Module/Build/Changes b/lib/Module/Build/Changes index 66fba3a..f421599 100644 --- a/lib/Module/Build/Changes +++ b/lib/Module/Build/Changes @@ -1,5 +1,41 @@ Revision history for Perl extension Module::Build. +0.31_04 - Fri Feb 20 11:04:59 PST 2009 + + Other + - Bumped Test::Harness prereq to 3.16 for latest PERL5LIB fixes (solves + test failures when installing Module::Build using CPANPLUS::Dist::Build) + [David Golden] + +0.31_03 - Sun Feb 8 14:54:01 PST 2009 + + Enhancements + - added a "prereq_data" action that prints a Perl data structure of + all prerequisites; can be loaded by external tools using eval() + [David Golden] + + Bug-fixes + - 'fakeinstall' action warns and skips without ExtUtils::Install 1.32+ + [David Golden, reported by Zefram] + - allows Module::Build version mismatch when installing self; works around + limitations in CPANPLUS::Dist::Build [David Golden] + +0.31_02 - Tue Jan 27 09:16:43 PST 2009 + + Other + - tests now use File::Temp (added to build_requires); appears to fix + Win32 testing heisenbug on directory removal during high system loads + - use_tap_harness.t will skip unless a release version of TAP::Harness + is installed + - improved diagnostics to ensure_blib() tests in t/lib/MBTest.pm + + Compat + - passthrough Makefile.PL will now play nice with cpantesters' on + exit(0) (RT#32018) [Eric Wilhelm] + + Bug Fixes + - fix for doubling-up of --prefix (RT#19951) + 0.31012 - Wed Jan 14 01:36:19 PST 2009 Bug Fixes diff --git a/lib/Module/Build/Compat.pm b/lib/Module/Build/Compat.pm index 328d070..f6c7c62 100644 --- a/lib/Module/Build/Compat.pm +++ b/lib/Module/Build/Compat.pm @@ -2,7 +2,7 @@ package Module::Build::Compat; use strict; use vars qw($VERSION); -$VERSION = '0.31012'; +$VERSION = '0.31_04'; use File::Spec; use IO::File; @@ -143,6 +143,7 @@ EOF eval "use Module::Build::Compat 0.02; 1" or die $@; %s Module::Build::Compat->run_build_pl(args => \@ARGV); + exit(0) unless(-e 'Build'); # cpantesters convention require %s; Module::Build::Compat->write_makefile(build_class => '%s'); EOF diff --git a/lib/Module/Build/Config.pm b/lib/Module/Build/Config.pm index 9e82365..41533d6 100644 --- a/lib/Module/Build/Config.pm +++ b/lib/Module/Build/Config.pm @@ -2,7 +2,7 @@ package Module::Build::Config; use strict; use vars qw($VERSION); -$VERSION = '0.31012'; +$VERSION = '0.31_04'; $VERSION = eval $VERSION; use Config; diff --git a/lib/Module/Build/Cookbook.pm b/lib/Module/Build/Cookbook.pm index 1567566..2c34f1b 100644 --- a/lib/Module/Build/Cookbook.pm +++ b/lib/Module/Build/Cookbook.pm @@ -1,7 +1,7 @@ package Module::Build::Cookbook; use strict; use vars qw($VERSION); -$VERSION = '0.31012'; +$VERSION = '0.31_04'; =head1 NAME diff --git a/lib/Module/Build/Dumper.pm b/lib/Module/Build/Dumper.pm index 909458a..7a10d85 100644 --- a/lib/Module/Build/Dumper.pm +++ b/lib/Module/Build/Dumper.pm @@ -1,7 +1,7 @@ package Module::Build::Dumper; use strict; use vars qw($VERSION); -$VERSION = '0.31012'; +$VERSION = '0.31_04'; # This is just a split-out of a wrapper function to do Data::Dumper # stuff "the right way". See: diff --git a/lib/Module/Build/ModuleInfo.pm b/lib/Module/Build/ModuleInfo.pm index 90f1be1..aa792b6 100644 --- a/lib/Module/Build/ModuleInfo.pm +++ b/lib/Module/Build/ModuleInfo.pm @@ -8,7 +8,7 @@ package Module::Build::ModuleInfo; use strict; use vars qw($VERSION); -$VERSION = '0.31012'; +$VERSION = '0.31_04'; $VERSION = eval $VERSION; use File::Spec; diff --git a/lib/Module/Build/Notes.pm b/lib/Module/Build/Notes.pm index 1235b14..50613c8 100644 --- a/lib/Module/Build/Notes.pm +++ b/lib/Module/Build/Notes.pm @@ -4,7 +4,7 @@ package Module::Build::Notes; use strict; use vars qw($VERSION); -$VERSION = '0.31012'; +$VERSION = '0.31_04'; $VERSION = eval $VERSION; use Data::Dumper; use IO::File; diff --git a/lib/Module/Build/PPMMaker.pm b/lib/Module/Build/PPMMaker.pm index 1cc8324..5a86e2d 100644 --- a/lib/Module/Build/PPMMaker.pm +++ b/lib/Module/Build/PPMMaker.pm @@ -2,7 +2,7 @@ package Module::Build::PPMMaker; use strict; use vars qw($VERSION); -$VERSION = '0.31012'; +$VERSION = '0.31_04'; $VERSION = eval $VERSION; # This code is mostly borrowed from ExtUtils::MM_Unix 6.10_03, with a diff --git a/lib/Module/Build/Platform/Amiga.pm b/lib/Module/Build/Platform/Amiga.pm index 2d206e1..d75871e 100644 --- a/lib/Module/Build/Platform/Amiga.pm +++ b/lib/Module/Build/Platform/Amiga.pm @@ -2,7 +2,7 @@ package Module::Build::Platform::Amiga; use strict; use vars qw($VERSION); -$VERSION = '0.31012'; +$VERSION = '0.31_04'; $VERSION = eval $VERSION; use Module::Build::Base; diff --git a/lib/Module/Build/Platform/Default.pm b/lib/Module/Build/Platform/Default.pm index 6da9891..07f30c5 100644 --- a/lib/Module/Build/Platform/Default.pm +++ b/lib/Module/Build/Platform/Default.pm @@ -2,7 +2,7 @@ package Module::Build::Platform::Default; use strict; use vars qw($VERSION); -$VERSION = '0.31012'; +$VERSION = '0.31_04'; $VERSION = eval $VERSION; use Module::Build::Base; diff --git a/lib/Module/Build/Platform/EBCDIC.pm b/lib/Module/Build/Platform/EBCDIC.pm index 752960c..15a0006 100644 --- a/lib/Module/Build/Platform/EBCDIC.pm +++ b/lib/Module/Build/Platform/EBCDIC.pm @@ -2,7 +2,7 @@ package Module::Build::Platform::EBCDIC; use strict; use vars qw($VERSION); -$VERSION = '0.31012'; +$VERSION = '0.31_04'; $VERSION = eval $VERSION; use Module::Build::Base; diff --git a/lib/Module/Build/Platform/MPEiX.pm b/lib/Module/Build/Platform/MPEiX.pm index 59b06ae..c6ee04f 100644 --- a/lib/Module/Build/Platform/MPEiX.pm +++ b/lib/Module/Build/Platform/MPEiX.pm @@ -2,7 +2,7 @@ package Module::Build::Platform::MPEiX; use strict; use vars qw($VERSION); -$VERSION = '0.31012'; +$VERSION = '0.31_04'; $VERSION = eval $VERSION; use Module::Build::Base; diff --git a/lib/Module/Build/Platform/MacOS.pm b/lib/Module/Build/Platform/MacOS.pm index 8030c0f..4e9f06f 100644 --- a/lib/Module/Build/Platform/MacOS.pm +++ b/lib/Module/Build/Platform/MacOS.pm @@ -2,7 +2,7 @@ package Module::Build::Platform::MacOS; use strict; use vars qw($VERSION); -$VERSION = '0.31012'; +$VERSION = '0.31_04'; $VERSION = eval $VERSION; use Module::Build::Base; use vars qw(@ISA); diff --git a/lib/Module/Build/Platform/RiscOS.pm b/lib/Module/Build/Platform/RiscOS.pm index 7b2dcb8..237d9c3 100644 --- a/lib/Module/Build/Platform/RiscOS.pm +++ b/lib/Module/Build/Platform/RiscOS.pm @@ -2,7 +2,7 @@ package Module::Build::Platform::RiscOS; use strict; use vars qw($VERSION); -$VERSION = '0.31012'; +$VERSION = '0.31_04'; $VERSION = eval $VERSION; use Module::Build::Base; diff --git a/lib/Module/Build/Platform/Unix.pm b/lib/Module/Build/Platform/Unix.pm index 5a424ac..abf0844 100644 --- a/lib/Module/Build/Platform/Unix.pm +++ b/lib/Module/Build/Platform/Unix.pm @@ -2,7 +2,7 @@ package Module::Build::Platform::Unix; use strict; use vars qw($VERSION); -$VERSION = '0.31012'; +$VERSION = '0.31_04'; $VERSION = eval $VERSION; use Module::Build::Base; diff --git a/lib/Module/Build/Platform/VMS.pm b/lib/Module/Build/Platform/VMS.pm index 2353e02..7584bae 100644 --- a/lib/Module/Build/Platform/VMS.pm +++ b/lib/Module/Build/Platform/VMS.pm @@ -2,7 +2,7 @@ package Module::Build::Platform::VMS; use strict; use vars qw($VERSION); -$VERSION = '0.31012'; +$VERSION = '0.31_04'; $VERSION = eval $VERSION; use Module::Build::Base; diff --git a/lib/Module/Build/Platform/VOS.pm b/lib/Module/Build/Platform/VOS.pm index f35dfff..ec7962c 100644 --- a/lib/Module/Build/Platform/VOS.pm +++ b/lib/Module/Build/Platform/VOS.pm @@ -2,7 +2,7 @@ package Module::Build::Platform::VOS; use strict; use vars qw($VERSION); -$VERSION = '0.31012'; +$VERSION = '0.31_04'; $VERSION = eval $VERSION; use Module::Build::Base; diff --git a/lib/Module/Build/Platform/Windows.pm b/lib/Module/Build/Platform/Windows.pm index bef4dc3..829c98d 100644 --- a/lib/Module/Build/Platform/Windows.pm +++ b/lib/Module/Build/Platform/Windows.pm @@ -2,7 +2,7 @@ package Module::Build::Platform::Windows; use strict; use vars qw($VERSION); -$VERSION = '0.31012'; +$VERSION = '0.31_04'; $VERSION = eval $VERSION; use Config; diff --git a/lib/Module/Build/Platform/aix.pm b/lib/Module/Build/Platform/aix.pm index fed1f5a..440abba 100644 --- a/lib/Module/Build/Platform/aix.pm +++ b/lib/Module/Build/Platform/aix.pm @@ -2,7 +2,7 @@ package Module::Build::Platform::aix; use strict; use vars qw($VERSION); -$VERSION = '0.31012'; +$VERSION = '0.31_04'; $VERSION = eval $VERSION; use Module::Build::Platform::Unix; diff --git a/lib/Module/Build/Platform/cygwin.pm b/lib/Module/Build/Platform/cygwin.pm index 6b15e7a..71717c0 100644 --- a/lib/Module/Build/Platform/cygwin.pm +++ b/lib/Module/Build/Platform/cygwin.pm @@ -2,7 +2,7 @@ package Module::Build::Platform::cygwin; use strict; use vars qw($VERSION); -$VERSION = '0.31012'; +$VERSION = '0.31_04'; $VERSION = eval $VERSION; use Module::Build::Platform::Unix; diff --git a/lib/Module/Build/Platform/darwin.pm b/lib/Module/Build/Platform/darwin.pm index 5a381d8..bc0f7a7 100644 --- a/lib/Module/Build/Platform/darwin.pm +++ b/lib/Module/Build/Platform/darwin.pm @@ -2,7 +2,7 @@ package Module::Build::Platform::darwin; use strict; use vars qw($VERSION); -$VERSION = '0.31012'; +$VERSION = '0.31_04'; $VERSION = eval $VERSION; use Module::Build::Platform::Unix; diff --git a/lib/Module/Build/Platform/os2.pm b/lib/Module/Build/Platform/os2.pm index 42d9b5e..54f4100 100644 --- a/lib/Module/Build/Platform/os2.pm +++ b/lib/Module/Build/Platform/os2.pm @@ -2,7 +2,7 @@ package Module::Build::Platform::os2; use strict; use vars qw($VERSION); -$VERSION = '0.31012'; +$VERSION = '0.31_04'; $VERSION = eval $VERSION; use Module::Build::Platform::Unix; diff --git a/lib/Module/Build/PodParser.pm b/lib/Module/Build/PodParser.pm index 1964f00..79ddab5 100644 --- a/lib/Module/Build/PodParser.pm +++ b/lib/Module/Build/PodParser.pm @@ -2,7 +2,7 @@ package Module::Build::PodParser; use strict; use vars qw($VERSION); -$VERSION = '0.31012'; +$VERSION = '0.31_04'; $VERSION = eval $VERSION; use vars qw(@ISA); diff --git a/lib/Module/Build/scripts/bundle.pl b/lib/Module/Build/scripts/bundle.pl old mode 100644 new mode 100755 diff --git a/lib/Module/Build/t/compat.t b/lib/Module/Build/t/compat.t index d12898b..86e6869 100644 --- a/lib/Module/Build/t/compat.t +++ b/lib/Module/Build/t/compat.t @@ -215,23 +215,31 @@ ok $mb, "Module::Build->new_from_context"; 'Should be non-verbose'; (my $libdir2 = $libdir) =~ s/libdir/lbiidr/; - my @make_args = ('INSTALLDIRS=vendor', "INSTALLVENDORLIB=$libdir2"); - if ($is_vms_mms) { # VMS MMK/MMS macros use different syntax. - $make_args[0] = '/macro=("' . join('","',@make_args) . '")'; - pop @make_args while scalar(@make_args) > 1; - } - ($output) = stdout_stderr_of( - sub { - $ran_ok = $mb->do_system(@make, 'fakeinstall', @make_args); + SKIP: { + require ExtUtils::Install; + skip "Needs ExtUtils::Install 1.32 or later", 2 + if ExtUtils::Install->VERSION < 1.32; + + my @make_args = ('INSTALLDIRS=vendor', "INSTALLVENDORLIB=$libdir2"); + + if ($is_vms_mms) { # VMS MMK/MMS macros use different syntax. + $make_args[0] = '/macro=("' . join('","',@make_args) . '")'; + pop @make_args while scalar(@make_args) > 1; } - ); - ok $ran_ok, "make fakeinstall with INSTALLDIRS=vendor ran ok"; - $output =~ s/^/# /gm; # Don't confuse our own test output - like $output, - qr/\Q$libdir2\E .* Simple\.pm/x, - 'Should have installdirs=vendor'; + ($output) = stdout_stderr_of( + sub { + $ran_ok = $mb->do_system(@make, 'fakeinstall', @make_args); + } + ); + + ok $ran_ok, "make fakeinstall with INSTALLDIRS=vendor ran ok"; + $output =~ s/^/# /gm; # Don't confuse our own test output + like $output, + qr/\Q$libdir2\E .* Simple\.pm/x, + 'Should have installdirs=vendor'; + } stdout_of( sub { $mb->do_system(@make, 'realclean'); } ); ok ! -e $makefile, "$makefile shouldn't exist"; diff --git a/lib/Module/Build/t/compat/exit.t b/lib/Module/Build/t/compat/exit.t new file mode 100755 index 0000000..b0fbf4c --- /dev/null +++ b/lib/Module/Build/t/compat/exit.t @@ -0,0 +1,52 @@ +#!/usr/bin/perl -w + +use strict; + +use lib $ENV{PERL_CORE} ? '../lib/Module/Build/t/lib' : 't/lib'; +use MBTest tests => 5; + +use_ok 'Module::Build'; +ensure_blib('Module::Build'); + +######################### + +my $tmp = MBTest->tmpdir; + +# Create test distribution; set requires and build_requires +use DistGen; +my $dist = DistGen->new( dir => $tmp ); + +$dist->regen; + +$dist->chdir_in; + +######################### + +my $mb; stdout_of(sub{ $mb = Module::Build->new_from_context}); + +use Module::Build::Compat; + +$dist->regen; + +Module::Build::Compat->create_makefile_pl('passthrough', $mb); + +# as silly as all of this exit(0) business is, that is what the cpan +# testers have instructed everybody to do so... +$dist->change_file('Build.PL' => + "warn qq(you have no libthbbt\n); exit;\n" . $dist->get_file('Build.PL') +); + +$dist->regen; + +stdout_of(sub{ $mb->ACTION_realclean }); + +my $result; +my ($stdout, $stderr ) = stdout_stderr_of (sub { + $result = $mb->run_perl_script('Makefile.PL'); +}); +ok $result, "Makefile.PL exit"; +like $stdout, qr/running Build\.PL/; +like $stderr, qr/you have no libthbbt$/; +#warn "out: $stdout"; warn "err: $stderr"; + +# vim:ts=2:sw=2:et:sta diff --git a/lib/Module/Build/t/ext.t b/lib/Module/Build/t/ext.t index 3730ef0..3b01a79 100644 --- a/lib/Module/Build/t/ext.t +++ b/lib/Module/Build/t/ext.t @@ -136,12 +136,10 @@ foreach my $test (@win_splits) { { # Make sure run_perl_script() propagates @INC - my $dir = 'whosiewhatzit'; - mkdir $dir, 0777; + my $dir = MBTest->tmpdir; local @INC = ($dir, @INC); my $output = stdout_of( sub { Module::Build->run_perl_script('-le', [], ['print for @INC']) } ); - like $output, qr{^$dir}m; - rmdir $dir; + like $output, qr{^\Q$dir\E}m; } ################################################################## diff --git a/lib/Module/Build/t/files.t b/lib/Module/Build/t/files.t index fde77cf..9ee452e 100644 --- a/lib/Module/Build/t/files.t +++ b/lib/Module/Build/t/files.t @@ -2,7 +2,7 @@ use strict; use lib $ENV{PERL_CORE} ? '../lib/Module/Build/t/lib' : 't/lib'; -use MBTest tests => 8; +use MBTest tests => 6; use_ok 'Module::Build'; ensure_blib('Module::Build'); @@ -16,36 +16,24 @@ $dist->regen; $dist->chdir_in; - - my $mb = Module::Build->new_from_context; -my @files; { # Make sure copy_if_modified() can handle spaces in filenames my @tmp; - foreach (1..2) { - my $tmp = File::Spec->catdir('t', "tmp$_"); - $mb->add_to_cleanup($tmp); - push @files, $tmp; - unless (-d $tmp) { - mkdir($tmp, 0777) or die "Can't create $tmp: $!"; - } - ok -d $tmp; - $tmp[$_] = $tmp; - } + push @tmp, MBTest->tmpdir for (0 .. 1); my $filename = 'file with spaces.txt'; - my $file = File::Spec->catfile($tmp[1], $filename); + my $file = File::Spec->catfile($tmp[0], $filename); my $fh = IO::File->new($file, '>') or die "Can't create $file: $!"; print $fh "Foo\n"; $fh->close; ok -e $file; - my $file2 = $mb->copy_if_modified(from => $file, to_dir => $tmp[2]); + my $file2 = $mb->copy_if_modified(from => $file, to_dir => $tmp[1]); ok $file2; ok -e $file2; } diff --git a/lib/Module/Build/t/lib/DistGen.pm b/lib/Module/Build/t/lib/DistGen.pm index e1e51f9..98a3d1b 100644 --- a/lib/Module/Build/t/lib/DistGen.pm +++ b/lib/Module/Build/t/lib/DistGen.pm @@ -405,6 +405,12 @@ sub change_build_pl { use strict; use Module::Build; my \$b = Module::Build->new( + # Some CPANPLUS::Dist::Build versions need to allow mismatches + # On logic: thanks to Module::Install, CPAN.pm must set both keys, but + # CPANPLUS sets only the one + allow_mb_mismatch => ( + \$ENV{PERL5_CPANPLUS_IS_RUNNING} && ! \$ENV{PERL5_CPAN_IS_RUNNING} ? 1 : 0 + ), $args ); \$b->create_build_script(); @@ -419,6 +425,13 @@ sub change_file { $self->{pending}{change}{$file} = 1; } +sub get_file { + my $self = shift; + my $file = shift; + exists($self->{filedata}{$file}) or croak("no such entry: '$file'"); + return $self->{filedata}{$file}; +} + sub chdir_in { my $self = shift; diff --git a/lib/Module/Build/t/lib/MBTest.pm b/lib/Module/Build/t/lib/MBTest.pm index d6e5178..291b196 100644 --- a/lib/Module/Build/t/lib/MBTest.pm +++ b/lib/Module/Build/t/lib/MBTest.pm @@ -3,6 +3,7 @@ package MBTest; use strict; use File::Spec; +use File::Temp (); use File::Path (); @@ -76,7 +77,7 @@ use Cwd (); # We pass everything through to Test::More use vars qw($VERSION @ISA @EXPORT %EXPORT_TAGS $TODO); -$VERSION = 0.01; +$VERSION = 0.01_01; @ISA = qw(Test::More); # Test::More isa Exporter @EXPORT = @Test::More::EXPORT; %EXPORT_TAGS = %Test::More::EXPORT_TAGS; @@ -100,18 +101,13 @@ __PACKAGE__->export(scalar caller, @extra_exports); ######################################################################## -{ # Setup a temp directory if it doesn't exist +# always return to the current directory +{ my $cwd = Cwd::cwd; - my $tmp = File::Spec->catdir( $cwd, 't', '_tmp' . $$); - mkdir $tmp, 0777 unless -d $tmp; - sub tmpdir { $tmp } END { - if(-d $tmp) { - # Go back to where you came from! - chdir $cwd or die "Couldn't chdir to $cwd"; - File::Path::rmtree($tmp) or diag "cannot clean dir '$tmp'"; - } + # Go back to where you came from! + chdir $cwd or die "Couldn't chdir to $cwd"; } } ######################################################################## @@ -125,6 +121,13 @@ __PACKAGE__->export(scalar caller, @extra_exports); } ######################################################################## +# Setup a temp directory +sub tmpdir { + return File::Temp::tempdir( 'MB-XXXXXXXX', + CLEANUP => 1, DIR => $ENV{PERL_CORE} ? Cwd::cwd : File::Spec->tmpdir + ); +} + sub save_handle { my ($handle, $subr) = @_; my $outfile = temp_file_name(); @@ -209,10 +212,14 @@ sub ensure_blib { # Make sure the given module was loaded from blib/, not the larger system my $mod = shift; (my $path = $mod) =~ s{::}{/}g; - + + local $Test::Builder::Level = $Test::Builder::Level + 1; SKIP: { skip "no blib in core", 1 if $ENV{PERL_CORE}; - like $INC{"$path.pm"}, qr/\bblib\b/, "Make sure $mod was loaded from blib/"; + like $INC{"$path.pm"}, qr/\bblib\b/, "Make sure $mod was loaded from blib/" + or diag "PERL5LIB: " . ($ENV{PERL5LIB} || '') . "\n" . + "PERL5OPT: " . ($ENV{PERL5OPT} || '') . "\n" . + "\@INC contains:\n " . join("\n ", @INC) . "\n"; } } diff --git a/lib/Module/Build/t/use_tap_harness.t b/lib/Module/Build/t/use_tap_harness.t index b6d0598..31f3210 100644 --- a/lib/Module/Build/t/use_tap_harness.t +++ b/lib/Module/Build/t/use_tap_harness.t @@ -3,10 +3,10 @@ use strict; use Test::More; use lib $ENV{PERL_CORE} ? '../lib/Module/Build/t/lib' : 't/lib'; -if (eval { require TAP::Parser }) { +if (eval { require TAP::Harness } && TAP::Harness->VERSION >= 3) { plan tests => 8; } else { - plan skip_all => 'TAP::Parser not installed' + plan skip_all => 'TAP::Harness 3+ not installed' } use MBTest;