summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--t/003-subprocess.t12
1 files changed, 9 insertions, 3 deletions
diff --git a/t/003-subprocess.t b/t/003-subprocess.t
index bb6b093..c5d17bd 100644
--- a/t/003-subprocess.t
+++ b/t/003-subprocess.t
@@ -5,11 +5,17 @@ use Test::More tests => 2;
use IO::Pty::Easy;
my $pty = new IO::Pty::Easy;
-my $script = "$^X -e '-t *STDIN && -t *STDOUT && print \"ok\";'";
+my $script = << 'EOF';
+$| = 1;
+if (-t *STDIN && -t *STDOUT) { print "ok" }
+else { print "failed" }
+EOF
-my $outside_of_pty = `$script`;
+my $outside_of_pty = `$^X -e '$script'`;
unlike($outside_of_pty, qr/ok/, "running outside of pty fails -t checks");
-$pty->spawn("$script");
+# 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->kill;