Author: ericwilhelm
Date: Mon Jan 12 18:28:10 2009
New Revision: 12419

Added:
   Module-Build/trunk/t/compat/
   Module-Build/trunk/t/compat/exit.t   (contents, props changed)
Modified:
   Module-Build/trunk/Changes
   Module-Build/trunk/MANIFEST
   Module-Build/trunk/lib/Module/Build/Compat.pm
   Module-Build/trunk/t/lib/DistGen.pm

Log:
lib/Module/Build/Compat.pm - deal with Build.PL doing exit() with passthrough
t/lib/DistGen.pm           - added a get_file() method
t/compat/exit.t            - cover the case of exit(0)
MANIFEST                   - regen
Changes                    - update


Modified: Module-Build/trunk/Changes
==============================================================================
--- Module-Build/trunk/Changes  (original)
+++ Module-Build/trunk/Changes  Mon Jan 12 18:28:10 2009
@@ -2,6 +2,9 @@
 
 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
 

Modified: Module-Build/trunk/MANIFEST
==============================================================================
--- Module-Build/trunk/MANIFEST (original)
+++ Module-Build/trunk/MANIFEST Mon Jan 12 18:28:10 2009
@@ -41,6 +41,7 @@
 t/basic.t
 t/bundled/Tie/CPHash.pm
 t/compat.t
+t/compat/exit.t
 t/destinations.t
 t/ext.t
 t/extend.t

Modified: Module-Build/trunk/lib/Module/Build/Compat.pm
==============================================================================
--- Module-Build/trunk/lib/Module/Build/Compat.pm       (original)
+++ Module-Build/trunk/lib/Module/Build/Compat.pm       Mon Jan 12 18:28:10 2009
@@ -143,6 +143,7 @@
     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

Added: Module-Build/trunk/t/compat/exit.t
==============================================================================
--- (empty file)
+++ Module-Build/trunk/t/compat/exit.t  Mon Jan 12 18:28:10 2009
@@ -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

Modified: Module-Build/trunk/t/lib/DistGen.pm
==============================================================================
--- Module-Build/trunk/t/lib/DistGen.pm (original)
+++ Module-Build/trunk/t/lib/DistGen.pm Mon Jan 12 18:28:10 2009
@@ -419,6 +419,13 @@
   $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;
 

Reply via email to