[tapx-dev] [commit] [130] Made T::P::I:: Process use open3 for both merged and non-merged
andy at hexten.net
andy at hexten.net
Thu Mar 15 17:30:37 GMT 2007
Revision: 130
Author: andy
Date: 2007-03-15 17:30:37 +0000 (Thu, 15 Mar 2007)
Log Message:
-----------
Made T::P::I::Process use open3 for both merged and non-merged
streams so that it works on Windows.
Modified Paths:
--------------
trunk/Changes
trunk/lib/TAP/Parser/Iterator/Process.pm
Modified: trunk/Changes
===================================================================
--- trunk/Changes 2007-03-15 17:18:19 UTC (rev 129)
+++ trunk/Changes 2007-03-15 17:30:37 UTC (rev 130)
@@ -22,6 +22,8 @@
TAP::Parser::Source, TAP::Parser and TAP::Harness.
- Added --merge option to runtests to enable STDOUT/STDERR merging.
This behaviour used to be the default.
+ - Made T::P::I::Process use open3 for both merged and non-merged
+ streams so that it works on Windows.
0.51 12 March 2007
- 'execrc' file now allows 'regex' matches for tests.
Modified: trunk/lib/TAP/Parser/Iterator/Process.pm
===================================================================
--- trunk/lib/TAP/Parser/Iterator/Process.pm 2007-03-15 17:18:19 UTC (rev 129)
+++ trunk/lib/TAP/Parser/Iterator/Process.pm 2007-03-15 17:30:37 UTC (rev 130)
@@ -70,15 +70,18 @@
*_wait2exit = sub { POSIX::WEXITSTATUS( $_[1] ) }
}
-sub _open_process_merged {
+sub _open_process {
my $self = shift;
+ my $merged = shift;
my @command = @_;
my $out = IO::Handle->new;
my $pid;
- eval { $pid = open3( undef, $out, undef, @command ); };
+ my $err = $merged ? undef : '>&STDERR';
+ eval { $pid = open3( undef, $out, $err, @command ); };
+
if ($@) {
# TODO: Need to do something better with the error info here.
@@ -98,20 +101,6 @@
return ( $out, $pid );
}
-sub _open_process {
- my $self = shift;
- my @command = @_;
-
- my $pid = open( my $out, '-|' );
- die "Could not fork: $!" unless defined $pid;
-
- if ( 0 == $pid ) {
- exec(@command) or die "Could not execute (@command): $!";
- }
-
- return ( $out, $pid );
-}
-
sub new {
my $class = shift;
my $args = shift;
@@ -122,9 +111,7 @@
my $self = bless { exit => undef }, $class;
- my ( $out, $pid ) = $merge
- ? $self->_open_process_merged(@command)
- : $self->_open_process(@command);
+ my ($out, $pid) = $self->_open_process($merge, @command);
$self->{out} = $out;
$self->{pid} = $pid;
More information about the tapx-dev
mailing list