IO-Pty-Easy
view release on metacpan or search on metacpan
t/subprocess.t view on Meta::CPAN
my $pty = IO::Pty::Easy->new;
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;
done_testing;
( run in 0.495 second using v1.01-cache-2.11-cpan-39bf76dae61 )