summaryrefslogtreecommitdiffstats
path: root/t/003-subprocess.t
blob: 352b7b46ebb70c342dc1aea294b5c79813c568ac (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!perl
use strict;
use warnings;
use Test::More tests => 2;
use IO::Pty::Easy;

my $pty = new IO::Pty::Easy;
my $script = << 'EOF';
$| = 1;
if (-t *STDIN && -t *STDOUT) { print "ok" }
else { print "failed" }
EOF

my $outside_of_pty = `$^X -e '$script'`;
unlike($outside_of_pty, qr/ok/, "running outside of pty fails -t checks");

# we need to keep the script alive until we can read the output from it
$script .= "sleep 1 while 1;";
$pty->spawn("$^X -e '$script'");
like($pty->read, qr/ok/, "runs subprocess in a pty");
$pty->close;