which tests this script:#!/usr/bin/perl -w # use Test::More tests => 3; use IPC::Open3; $script = './test1-script.pl'; eval { local $SIG{ALRM} = sub { die "not completed\n" }; alarm(5); #----------------------- 1 --------------------------- $pid = open3($in, $out, $err, $script); print $in "q\n"; like(<$out>, qr/^QUIT$/,"Quit"); waitpid($pid, 0); #----------------------- 2 --------------------------- $pid = open3($in, $out, $err, $script); close $in; like(<$out>, qr/^EOI$/,"End of input"); waitpid($pid, 0); }; unlike($@, qr/^not completed$/, "All tests completed in time");
#!/usr/bin/perl while(1) { if (eof(STDIN)) { print "EOI\n"; exit; } $_ = <STDIN>; if (/^q/i) { print "QUIT\n"; exit; } print; }
In reply to Re: Testing an interactive script with EOF on input
by mamawe
in thread Solved: Testing an interactive script with EOF on input
by mamawe
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |