Re: [PATCH] ExtUtils::MakeMaker 6.10_02
[p5sagit/p5-mst-13.2.git] / t / lib / MakeMaker / Test / Utils.pm
index 9260faf..be3ec73 100644 (file)
@@ -12,7 +12,7 @@ require Exporter;
 $VERSION = 0.02;
 
 @EXPORT = qw(which_perl perl_lib makefile_name makefile_backup
-             make make_run make_macro calibrate_mtime
+             make make_run run make_macro calibrate_mtime
             );
 
 my $Is_VMS   = $^O eq 'VMS';
@@ -39,6 +39,8 @@ MakeMaker::Test::Utils - Utility routines for testing MakeMaker
 
   my $mtime         = calibrate_mtime;
 
+  my $out           = run($cmd);
+
 =head1 DESCRIPTION
 
 A consolidation of little utility functions used through out the
@@ -230,6 +232,34 @@ sub calibrate_mtime {
     return $mtime;
 }
 
+=item B<run>
+
+  my $out = run($command);
+  my @out = run($command);
+
+Runs the given $command as an external program returning at least STDOUT
+as $out.  If possible it will return STDOUT and STDERR combined as you
+would expect to see on a screen.
+
+=cut
+
+sub run {
+    my $cmd = shift;
+
+    require ExtUtils::MM;
+
+    # Unix can handle 2>&1 and OS/2 from 5.005_54 up.
+    # This makes our failure diagnostics nicer to read.
+    if( MM->os_flavor_is('Unix') or
+        ($] > 5.00554 and MM->os_flavor_is('OS/2'))
+      ) {
+        return `$cmd 2>&1`;
+    }
+    else {
+        return `$cmd`;
+    }
+}    
+
 =back
 
 =head1 AUTHOR