Author: dagolden
Date: Thu Jul 16 04:33:46 2009
New Revision: 13067

Added:
   Module-Build/trunk/t/debug.t   (contents, props changed)
Modified:
   Module-Build/trunk/Changes
   Module-Build/trunk/lib/Module/Build/Base.pm

Log:
Added --debug flag (RT#47933)

Modified: Module-Build/trunk/Changes
==============================================================================
--- Module-Build/trunk/Changes  (original)
+++ Module-Build/trunk/Changes  Thu Jul 16 04:33:46 2009
@@ -2,6 +2,10 @@
 
 0.34_01 - 
 
+ Enhancements:
+ - Added --debug flag to trace Build action execution (RT#47933)
+   [David Golden]
+
 0.34 - Tue Jul  7 16:56:47 EDT 2009
 
  No changes from 0.33_06

Modified: Module-Build/trunk/lib/Module/Build/Base.pm
==============================================================================
--- Module-Build/trunk/lib/Module/Build/Base.pm (original)
+++ Module-Build/trunk/lib/Module/Build/Base.pm Thu Jul 16 04:33:46 2009
@@ -191,6 +191,11 @@
   my $self = shift;
   $self->log_info(@_) if(ref($self) and $self->verbose);
 }
+sub log_debug {
+  my $self = shift;
+  print @_ if ref $self && $self->debug;
+}
+
 sub log_warn {
   # Try to make our call stack invisible
   shift;
@@ -920,6 +925,7 @@
   sign
   test_files
   verbose
+  debug
   xs_files
 );
 
@@ -1593,7 +1599,10 @@
   local $self->{action} = $action;
   my $method = $self->can_action( $action );
   die "No action '$action' defined, try running the 'help' action.\n" unless 
$method;
-  return $self->$method();
+  $self->log_debug("Starting ACTION_$action\n");
+  my $rc = $self->$method();
+  $self->log_debug("Finished ACTION_$action\n");
+  return $rc;
 }
 
 sub can_action {
@@ -1719,6 +1728,7 @@
     uninst
     use_rcfile
     verbose
+    debug
     sign
     use_tap_harness
   );

Added: Module-Build/trunk/t/debug.t
==============================================================================
--- (empty file)
+++ Module-Build/trunk/t/debug.t        Thu Jul 16 04:33:46 2009
@@ -0,0 +1,37 @@
+#!/usr/bin/perl -w
+
+use strict;
+use lib $ENV{PERL_CORE} ? '../lib/Module/Build/t/lib' : 't/lib';
+use MBTest tests => 3;
+
+require_ok('Module::Build');
+ensure_blib('Module::Build');
+
+my $tmp = MBTest->tmpdir;
+
+use DistGen;
+my $dist = DistGen->new( dir => $tmp );
+$dist->regen;
+END{ $dist->remove }
+
+$dist->chdir_in;
+
+#########################
+
+# Test debug output
+{
+  my $output;
+  $output = stdout_of sub {
+    Module::Build->run_perl_script('Build.PL', [], [])
+  };
+  $output = stdout_of sub {
+    Module::Build->run_perl_script('Build', [], ['--debug'])
+  };
+  like($output, '/Starting ACTION_build.*?Starting ACTION_code.*?Finished 
ACTION_code.*?Finished ACTION_build/ms',
+    "found nested ACTION_* debug statements"
+  );
+}
+
+#########################
+
+# cleanup

Reply via email to