X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Flib%2Fopen2.t;h=85b807c98aae79b5bf073b3d51a7a7a61517c152;hb=20822f61cc01ab34be1e17db483aceb9d5ec8fb7;hp=8dd786b76ec4d01770b4f7565c65989f2dd1e61c;hpb=7e1af8bca57f405a8444b575a870918a6d88fc5c;p=p5sagit%2Fp5-mst-13.2.git diff --git a/t/lib/open2.t b/t/lib/open2.t index 8dd786b..85b807c 100755 --- a/t/lib/open2.t +++ b/t/lib/open2.t @@ -1,37 +1,57 @@ #!./perl -w -use strict; BEGIN { chdir 't' if -d 't'; @INC = '../lib'; + require Config; import Config; + if (!$Config{'d_fork'} + # open2/3 supported on win32 (but not Borland due to CRT bugs) + && ($^O ne 'MSWin32' || $Config{'cc'} =~ /^bcc/i)) + { + print "1..0\n"; + exit 0; + } # make warnings fatal $SIG{__WARN__} = sub { die @_ }; } +use strict; use IO::Handle; use IPC::Open2; #require 'open2.pl'; use subs 'open2'; +my $perl = './perl'; + sub ok { my ($n, $result, $info) = @_; if ($result) { print "ok $n\n"; } else { - print "not ok $n\n"; + print "not ok $n\n"; print "# $info\n" if $info; } } +sub cmd_line { + if ($^O eq 'MSWin32') { + return qq/"$_[0]"/; + } + else { + return $_[0]; + } +} + my ($pid, $reaped_pid); STDOUT->autoflush; STDERR->autoflush; print "1..7\n"; -ok 1, $pid = open2 'READ', 'WRITE', $^X, '-e', 'print scalar '; +ok 1, $pid = open2 'READ', 'WRITE', $perl, '-e', + cmd_line('print scalar '); ok 2, print WRITE "hi kid\n"; -ok 3, eq "hi kid\n"; +ok 3, =~ /^hi kid\r?\n$/; ok 4, close(WRITE), $!; ok 5, close(READ), $!; $reaped_pid = waitpid $pid, 0;