Commit | Line | Data |
7e1af8bc |
1 | #!./perl -w |
7e1af8bc |
2 | |
3 | BEGIN { |
4 | chdir 't' if -d 't'; |
20822f61 |
5 | @INC = '../lib'; |
774d564b |
6 | require Config; import Config; |
f55ee38a |
7 | if (!$Config{'d_fork'} |
8 | # open2/3 supported on win32 (but not Borland due to CRT bugs) |
2986a63f |
9 | && (($^O ne 'MSWin32' && $^O ne 'NetWare') || $Config{'cc'} =~ /^bcc/i)) |
f55ee38a |
10 | { |
774d564b |
11 | print "1..0\n"; |
12 | exit 0; |
13 | } |
7e1af8bc |
14 | # make warnings fatal |
15 | $SIG{__WARN__} = sub { die @_ }; |
16 | } |
17 | |
71be2cbc |
18 | use strict; |
7e1af8bc |
19 | use IO::Handle; |
20 | use IPC::Open2; |
21 | #require 'open2.pl'; use subs 'open2'; |
22 | |
774d564b |
23 | my $perl = './perl'; |
24 | |
7e1af8bc |
25 | sub ok { |
26 | my ($n, $result, $info) = @_; |
27 | if ($result) { |
28 | print "ok $n\n"; |
29 | } |
30 | else { |
f55ee38a |
31 | print "not ok $n\n"; |
7e1af8bc |
32 | print "# $info\n" if $info; |
33 | } |
34 | } |
35 | |
f55ee38a |
36 | sub cmd_line { |
2986a63f |
37 | if ($^O eq 'MSWin32' || $^O eq 'NetWare') { |
f55ee38a |
38 | return qq/"$_[0]"/; |
39 | } |
40 | else { |
41 | return $_[0]; |
42 | } |
43 | } |
44 | |
7e1af8bc |
45 | my ($pid, $reaped_pid); |
46 | STDOUT->autoflush; |
47 | STDERR->autoflush; |
48 | |
49 | print "1..7\n"; |
50 | |
f55ee38a |
51 | ok 1, $pid = open2 'READ', 'WRITE', $perl, '-e', |
52 | cmd_line('print scalar <STDIN>'); |
7e1af8bc |
53 | ok 2, print WRITE "hi kid\n"; |
f55ee38a |
54 | ok 3, <READ> =~ /^hi kid\r?\n$/; |
7e1af8bc |
55 | ok 4, close(WRITE), $!; |
56 | ok 5, close(READ), $!; |
57 | $reaped_pid = waitpid $pid, 0; |
58 | ok 6, $reaped_pid == $pid, $reaped_pid; |
59 | ok 7, $? == 0, $?; |