diff options
author | jluehrs2 <jluehrs2@uiuc.edu> | 2007-08-20 22:34:12 -0500 |
---|---|---|
committer | jluehrs2 <jluehrs2@uiuc.edu> | 2007-08-20 22:34:12 -0500 |
commit | 435497f5c4928e3310cd7e845977bc3c28610d7f (patch) | |
tree | 957ebf753c24d62795f7086bd8e7cde18ec72daf | |
parent | d924a23abbd2f4848a6c156506d639d160476483 (diff) | |
download | io-pty-easy-435497f5c4928e3310cd7e845977bc3c28610d7f.tar.gz io-pty-easy-435497f5c4928e3310cd7e845977bc3c28610d7f.zip |
print something on success and failure, so that the read call doesn't block, and make sure that the spawned script survives long enough for us to read from it
-rw-r--r-- | t/003-subprocess.t | 12 |
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; |