In the executable script -- which we'll call login.pl -- I have the following code:
my $config = {}; print "Type your username: "; chomp ($config->{username} = <>); system "stty -echo" and croak "Unable to turn off echoing to STDOUT"; print "Type your password: "; chomp ($config->{password} = <>); print "\n"; system "stty echo" and croak "Unable to turn echoing to STDOUT back on";
It DWIMs. But now suppose that in one of my test files I want to call login.pl, have the user enter her username and password and then use that data to log in to a server. If the login is successful, a string will be returned whose content I would like to validate with Test::More::like. How can I do that?
I have found that if I enter this code directly in a file where Test::More has been used, the prompt is never printed but the program hangs. I've explored both Test::Expect and IPC::Run, but I haven't been able to match anything in the documentation of either module to my needs.
Suggestions? Thanks in advance.
In reply to Interactive prompts inside a test harness by jkeenan1
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |