Author: BINGOS
Date: Fri Feb  6 15:15:07 2009
New Revision: 12481

Modified:
   CPANPLUS-Dist-Build/trunk/lib/CPANPLUS/Dist/Build.pm

Log:
Changed all the mb->dispatch() calls to IPC::Cmd instead, just like CP::D::MM 
does

Modified: CPANPLUS-Dist-Build/trunk/lib/CPANPLUS/Dist/Build.pm
==============================================================================
--- CPANPLUS-Dist-Build/trunk/lib/CPANPLUS/Dist/Build.pm        (original)
+++ CPANPLUS-Dist-Build/trunk/lib/CPANPLUS/Dist/Build.pm        Fri Feb  6 
15:15:07 2009
@@ -486,16 +486,28 @@
             last RUN;
         }
 
-        my $build_output;
-        eval { _capture ( sub { $mb->dispatch('build', %buildflags) }, 
$verbose, \$build_output ) };
-        msg( $build_output, 0 );
-
-        if( $@ ) {
-            error(loc("Could not run '%1': %2", 'Build', "$@"));
+#        my $build_output;
+#        eval { _capture ( sub { $mb->dispatch('build', %buildflags) }, 
$verbose, \$build_output ) };
+#        msg( $build_output, 0 );
+
+#        if( $@ ) {
+#            error(loc("Could not run '%1': %2", 'Build', "$@"));
+#            $dist->status->build(0);
+#            $fail++; last RUN;
+#        }
+        my $captured;
+
+        unless ( scalar run(    command => [$perl, BUILD->($dir), $buildflags],
+                                buffer  => \$captured,
+                                verbose => $verbose ) 
+        ) {
+            error( loc( "Build failed: %1 %2", $!, $captured ) );
             $dist->status->build(0);
             $fail++; last RUN;
         }
 
+        msg( $captured, 0 );
+
         $dist->status->build(1);
 
         ### add this directory to your lib ###
@@ -508,10 +520,16 @@
         ### against 0.2607 on 26/1/2005
         unless( $skiptest ) {
             my $test_output;
-            eval { _capture ( sub { $mb->dispatch('test', %buildflags) }, 
$verbose, \$test_output ) };
-            msg( $test_output, 0 );
-            if( $@ ) {
-                error(loc("Could not run '%1': %2", 'Build test', "$@"));
+#            eval { _capture ( sub { $mb->dispatch('test', %buildflags) }, 
$verbose, \$test_output ) };
+#            msg( $test_output, 0 );
+            my $flag    = ON_VMS ? '"test"' : 'test';
+            my $cmd     = [$perl, BUILD->($dir), $flag, $buildflags];
+            unless ( scalar run(    command => $cmd,
+                                    buffer  => \$test_output,
+                                    verbose => $verbose ) 
+            ) {
+#                error(loc("Could not run '%1': %2", 'Build test', "$@"));
+                error( loc( "Build test failed: %1 %2", $!, $test_output ) );
 
                 ### mark specifically *test* failure.. so we dont
                 ### send success on force...
@@ -524,10 +542,13 @@
                     $fail++; last RUN;
                 }
 
-            } else {
+            } 
+            else {
+                msg( $test_output, 0 );
                 $dist->status->test(1);
             }
-        } else {
+        } 
+        else {
             msg(loc("Tests skipped"), $verbose);
         }
     }
@@ -641,12 +662,22 @@
         my %buildflags = $dist->_buildflags_as_hash($buildflags);
 
         my $install_output;
-        eval { _capture ( sub { $mb->dispatch('install', %buildflags) }, 
$verbose, \$install_output ) };
-        msg( $install_output, 0 );
-        if( $@ ) {
-            error(loc("Could not run '%1': %2", 'Build install', "$@"));
+#        eval { _capture ( sub { $mb->dispatch('install', %buildflags) }, 
$verbose, \$install_output ) };
+#        msg( $install_output, 0 );
+#        if( $@ ) {
+        my $flag    = ON_VMS ? '"install"' : 'install';
+        my $cmd     = [$perl, BUILD->($dir), $flag, $buildflags];
+        unless( scalar run( command => $cmd,
+                            buffer  => \$install_output,
+                            verbose => $verbose )
+        ) {
+#            error(loc("Could not run '%1': %2", 'Build install', "$@"));
+            error(loc("Could not run '%1': %2", 'Build install', 
$install_output));
             $fail++;
         }
+        else {
+            msg( $install_output, 0 );
+        }
     }
 
 

Reply via email to