jkeenan1 has asked for the wisdom of the Perl Monks concerning the following question:
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Interactive prompts inside a test harness
by Joost (Canon) on Nov 07, 2006 at 21:54 UTC | |
|
Re: Interactive prompts inside a test harness
by Old_Gray_Bear (Bishop) on Nov 08, 2006 at 00:42 UTC | |
|
Re: Interactive prompts inside a test harness
by Firefly258 (Beadle) on Nov 08, 2006 at 00:06 UTC | |
by jkeenan1 (Deacon) on Nov 08, 2006 at 02:04 UTC | |
|
Re: Interactive prompts inside a test harness
by jethro (Monsignor) on Nov 07, 2006 at 23:34 UTC | |
|
Re: Interactive prompts inside a test harness
by Anonymous Monk on Nov 08, 2006 at 04:38 UTC |