Author: dagolden
Date: Sun Aug 16 11:50:05 2009
New Revision: 13198

Modified:
   Module-Build/trunk/t/debug.t
   Module-Build/trunk/t/lib/DistGen.pm

Log:
add run_build_pl/run_build helpers to DistGen

Modified: Module-Build/trunk/t/debug.t
==============================================================================
--- Module-Build/trunk/t/debug.t        (original)
+++ Module-Build/trunk/t/debug.t        Sun Aug 16 11:50:05 2009
@@ -21,13 +21,8 @@
 # Test debug output
 {
   my $output;
-  $output = stdout_of sub {
-    Module::Build->run_perl_script('Build.PL', [], [])
-  };
-  my $build_script = $^O eq 'VMS' ? 'Build.com' : 'Build';
-  $output = stdout_of sub {
-    Module::Build->run_perl_script($build_script, [], ['--debug'])
-  };
+  $output = stdout_of sub { $dist->run_build_pl };
+  $output = stdout_of sub { $dist->run_build('--debug') };
   like($output, '/Starting ACTION_build.*?Starting ACTION_code.*?Finished 
ACTION_code.*?Finished ACTION_build/ms',
     "found nested ACTION_* debug statements"
   );

Modified: Module-Build/trunk/t/lib/DistGen.pm
==============================================================================
--- Module-Build/trunk/t/lib/DistGen.pm (original)
+++ Module-Build/trunk/t/lib/DistGen.pm Sun Aug 16 11:50:05 2009
@@ -489,6 +489,19 @@
 }
 ########################################################################
 
+sub run_build_pl {
+  my (@args) = @_;
+  require Module::Build;
+  Module::Build->run_perl_script('Build.PL', [], [...@args])
+}
+
+sub run_build {
+  my (@args) = @_;
+  require Module::Build;
+  my $build_script = $^O eq 'VMS' ? 'Build.com' : 'Build';
+  Module::Build->run_perl_script($build_script, [], [...@args])
+}
+
 1;
 
 __END__
@@ -516,6 +529,10 @@
   # clean up extraneous files
   $dist->clean;
 
+  # exercise the command-line interface
+  $dist->run_build_pl();
+  $dist->run_build('test');
+
   # finish testing and clean up
   $dist->chdir_original;
   $dist->remove;
@@ -546,6 +563,11 @@
   chdir_in
   chdir_original
 
+Additional methods portably encapsulate running Build.PL and Build:
+
+  run_build_pl
+  run_build
+
 =head1 API
 
 =head2 Constructor
@@ -699,6 +721,27 @@
 
   $dist->chdir_original;
 
+=head2 Command-line helpers
+
+These use Module::Build->run_perl_script() to ensure that Build.PL or Build are
+run in a separate process using the current perl interpreter.  (Module::Build
+is loaded on demand).  They also ensure appropriate naming for operating
+systems that require a suffix for Build.
+
+=head3 run_build_pl
+
+Runs Build.PL using the current perl interpreter.  Any arguments are
+passed on the command line.
+
+  $dist->run_build_pl('--quiet');
+
+=head3 run_build
+
+Runs Build using the current perl interpreter.  Any arguments are
+passed on the command line.
+
+  $dist->run_build(qw/test --verbose/);
+
 =head2 Properties
 
 =head3 name()

Reply via email to