diff options
author | Perl 5 Porters <perl5-porters@africa.nicoh.com> | 1996-12-20 11:14:00 +1200 |
---|---|---|
committer | Chip Salzenberg <chip@atlantic.net> | 1996-12-20 11:14:00 +1200 |
commit | 7e1af8bca57f405a8444b575a870918a6d88fc5c (patch) | |
tree | b443adc34d8d77831bf947076abd5770335592cf /t/lib/open3.t | |
parent | 7f3dfc00eaef7e421633b2b47af9963dbc626e75 (diff) | |
download | perl-7e1af8bca57f405a8444b575a870918a6d88fc5c.tar.gz |
[inseparable changes from patch from perl5.003_12 to perl5.003_13]
DOCUMENTATION
Subject: small doc tweaks for _12
Date: Thu, 19 Dec 1996 11:05:57 -0500
From: Roderick Schertler <roderick@gate.net>
Files: lib/UNIVERSAL.pm pod/perldiag.pod pod/perltie.pod
Msg-ID: <1826.851011557@eeyore.ibcinc.com>
(applied based on p5p patch as commit 3314ffc68a11690bd9977cbdd7ea0601ad6ced13)
PORTABILITY
Subject: Add missing backslash in Configure
From: Chip Salzenberg <chip@atlantic.net>
Files: Configure
UTILITIES, LIBRARY, AND EXTENSIONS
Subject: Include libnet-1.01 instead of old Net::FTP
From: Graham Barr <Graham.Barr@tiuk.ti.com>
Files: MANIFEST lib/Net/Cmd.pm lib/Net/Domain.pm lib/Net/DummyInetd.pm lib/Net/FTP.pm lib/Net/NNTP.pm lib/Net/Netrc.pm lib/Net/POP3.pm lib/Net/SMTP.pm lib/Net/SNPP.pm lib/Net/Socket.pm lib/Net/Telnet.pm lib/Net/Time.pm pod/perlmod.pod
Subject: Use binmode when doing binary FTP
From: Ilya Zakharevich <ilya@math.ohio-state.edu>
Files: lib/Net/FTP.pm
Subject: Re: Open3.pm tries to close unopened file handle
Date: 18 Dec 1996 22:19:54 -0500
From: Roderick Schertler <roderick@gate.net>
Files: MANIFEST lib/IPC/Open2.pm lib/IPC/Open3.pm lib/open2.pl lib/open3.pl pod/perldiag.pod pod/perlfunc.pod t/lib/open2.t t/lib/open3.t
Msg-ID: <pzloavmd9h.fsf@eeyore.ibcinc.com>
(applied based on p5p patch as commit 982b4e8fc47473059e209787b589853f4c8f8f9e)
Subject: Long-standing problem in Socket module
Date: Wed, 18 Dec 1996 23:18:14 -0500
From: Spider Boardman <spider@orb.nashua.nh.us>
Files: Configure Porting/Glossary config_H config_h.SH ext/Socket/Socket.pm ext/Socket/Socket.xs
Msg-ID: <199612190418.XAA07291@Orb.Nashua.NH.US>
(applied based on p5p patch as commit 3e6a22d2723daf415793f9a4fc1b57f4d8a576fd)
Subject: flock() constants
Date: Thu, 19 Dec 1996 01:37:17 -0500
From: Roderick Schertler <roderick@gate.net>
Files: ext/Fcntl/Fcntl.pm ext/Fcntl/Fcntl.xs pod/perlfunc.pod
Msg-ID: <26669.850977437@eeyore.ibcinc.com>
(applied based on p5p patch as commit 3dea0e15e4684f6defe2f25a16bc696b96697ac2)
Diffstat (limited to 't/lib/open3.t')
-rwxr-xr-x | t/lib/open3.t | 114 |
1 files changed, 114 insertions, 0 deletions
diff --git a/t/lib/open3.t b/t/lib/open3.t index e69de29bb2..a4a978ebea 100755 --- a/t/lib/open3.t +++ b/t/lib/open3.t @@ -0,0 +1,114 @@ +#!./perl -w +use strict; + +BEGIN { + chdir 't' if -d 't'; + @INC = '../lib'; + # make warnings fatal + $SIG{__WARN__} = sub { die @_ }; +} + +use IO::Handle; +use IPC::Open3; +#require 'open3.pl'; use subs 'open3'; + +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..21\n"; + +# basic +ok 1, $pid = open3 'WRITE', 'READ', 'ERROR', $^X, '-e', <<'EOF'; + $| = 1; + print scalar <STDIN>; + print STDERR "hi error\n"; +EOF +ok 2, print WRITE "hi kid\n"; +ok 3, <READ> eq "hi kid\n"; +ok 4, <ERROR> eq "hi error\n"; +ok 5, close(WRITE), $!; +ok 6, close(READ), $!; +ok 7, close(ERROR), $!; +$reaped_pid = waitpid $pid, 0; +ok 8, $reaped_pid == $pid, $reaped_pid; +ok 9, $? == 0, $?; + +# read and error together, both named +$pid = open3 'WRITE', 'READ', 'READ', $^X, '-e', <<'EOF'; + $| = 1; + print scalar <STDIN>; + print STDERR scalar <STDIN>; +EOF +print WRITE "ok 10\n"; +print scalar <READ>; +print WRITE "ok 11\n"; +print scalar <READ>; +waitpid $pid, 0; + +# read and error together, error empty +$pid = open3 'WRITE', 'READ', '', $^X, '-e', <<'EOF'; + $| = 1; + print scalar <STDIN>; + print STDERR scalar <STDIN>; +EOF +print WRITE "ok 12\n"; +print scalar <READ>; +print WRITE "ok 13\n"; +print scalar <READ>; +waitpid $pid, 0; + +# dup writer +ok 14, pipe PIPE_READ, PIPE_WRITE; +$pid = open3 '<&PIPE_READ', 'READ', '', + $^X, '-e', 'print scalar <STDIN>'; +close PIPE_READ; +print PIPE_WRITE "ok 15\n"; +close PIPE_WRITE; +print scalar <READ>; +waitpid $pid, 0; + +# dup reader +$pid = open3 'WRITE', '>&STDOUT', 'ERROR', + $^X, '-e', 'print scalar <STDIN>'; +print WRITE "ok 16\n"; +waitpid $pid, 0; + +# dup error: This particular case, duping stderr onto the existing +# stdout but putting stdout somewhere else, is a good case because it +# used not to work. +$pid = open3 'WRITE', 'READ', '>&STDOUT', + $^X, '-e', 'print STDERR scalar <STDIN>'; +print WRITE "ok 17\n"; +waitpid $pid, 0; + +# dup reader and error together, both named +$pid = open3 'WRITE', '>&STDOUT', '>&STDOUT', $^X, '-e', <<'EOF'; + $| = 1; + print STDOUT scalar <STDIN>; + print STDERR scalar <STDIN>; +EOF +print WRITE "ok 18\n"; +print WRITE "ok 19\n"; +waitpid $pid, 0; + +# dup reader and error together, error empty +$pid = open3 'WRITE', '>&STDOUT', '', $^X, '-e', <<'EOF'; + $| = 1; + print STDOUT scalar <STDIN>; + print STDERR scalar <STDIN>; +EOF +print WRITE "ok 20\n"; +print WRITE "ok 21\n"; +waitpid $pid, 0; |