X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Flib%2Fopen2.t;h=8dd786b76ec4d01770b4f7565c65989f2dd1e61c;hb=7e1af8bca57f405a8444b575a870918a6d88fc5c;hp=e69de29bb2d1d6434b8b29ae775ad8c2e48c5391;hpb=7f3dfc00eaef7e421633b2b47af9963dbc626e75;p=p5sagit%2Fp5-mst-13.2.git diff --git a/t/lib/open2.t b/t/lib/open2.t index e69de29..8dd786b 100755 --- a/t/lib/open2.t +++ b/t/lib/open2.t @@ -0,0 +1,39 @@ +#!./perl -w +use strict; + +BEGIN { + chdir 't' if -d 't'; + @INC = '../lib'; + # make warnings fatal + $SIG{__WARN__} = sub { die @_ }; +} + +use IO::Handle; +use IPC::Open2; +#require 'open2.pl'; use subs 'open2'; + +sub ok { + my ($n, $result, $info) = @_; + if ($result) { + print "ok $n\n"; + } + else { + print "not ok $n\n"; + print "# $info\n" if $info; + } +} + +my ($pid, $reaped_pid); +STDOUT->autoflush; +STDERR->autoflush; + +print "1..7\n"; + +ok 1, $pid = open2 'READ', 'WRITE', $^X, '-e', 'print scalar '; +ok 2, print WRITE "hi kid\n"; +ok 3, eq "hi kid\n"; +ok 4, close(WRITE), $!; +ok 5, close(READ), $!; +$reaped_pid = waitpid $pid, 0; +ok 6, $reaped_pid == $pid, $reaped_pid; +ok 7, $? == 0, $?;