diff options
Diffstat (limited to 't/subprocess.t')
-rw-r--r-- | t/subprocess.t | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/t/subprocess.t b/t/subprocess.t new file mode 100644 index 0000000..d889074 --- /dev/null +++ b/t/subprocess.t @@ -0,0 +1,23 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use Test::More; +use IO::Pty::Easy; + +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; |