From 435497f5c4928e3310cd7e845977bc3c28610d7f Mon Sep 17 00:00:00 2001 From: jluehrs2 Date: Mon, 20 Aug 2007 22:34:12 -0500 Subject: 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 --- t/003-subprocess.t | 12 +++++++++--- 1 file 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; -- cgit v1.2.3-54-g00ecf