Skip to content

Commit

Permalink
lib/Module/Build/Compat.pm - deal with Build.PL doing exit() with pas…
Browse files Browse the repository at this point in the history
…sthrough

t/lib/DistGen.pm           - added a get_file() method
t/compat/exit.t            - cover the case of exit(0)
MANIFEST                   - regen
Changes                    - update


git-svn-id: http://svn.perl.org/modules/Module-Build/trunk@12419 50811bd7-b8ce-0310-adc1-d9db26280581
  • Loading branch information
ewilhelm committed Jan 13, 2009
1 parent 7d32e56 commit 21f396e
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ Revision history for Perl extension Module::Build.

0.31_02

Compat
- passthrough Makefile.PL will now play nice with cpantesters' on
exit(0) (RT#32018) [Eric Wilhelm]

0.3101 - Mon Jan 12 13:52:36 PST 2009

Expand Down
1 change: 1 addition & 0 deletions MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ t/add_property.t
t/basic.t
t/bundled/Tie/CPHash.pm
t/compat.t
t/compat/exit.t
t/destinations.t
t/ext.t
t/extend.t
Expand Down
1 change: 1 addition & 0 deletions lib/Module/Build/Compat.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
52 changes: 52 additions & 0 deletions t/compat/exit.t
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions t/lib/DistGen.pm
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,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;

Expand Down

0 comments on commit 21f396e

Please sign in to comment.