in reply to Interactive prompts inside a test harness

Take a look at the Perl Testing, A Developer's Notebook, Langworth and chromatic, page 169 - "Testing Interactive Programs"; this is a quick write-up on Test::Expect. The example shown is a test harness for an iterative routine; it keeps prompting the User until it receives a 'quit-it' string ("\n" in this case).

Last Monday, I was also confronted with the need to automate 'Password, Please!' routine in a test-harness. I did a bit of research, read the PT section, and said "Eureka". I then ran into a spot of difficulty dealing with password prompting - I was only prompting one time and then moving on, rather than re-issuing a prompt in a loop and waiting for the User to say 'done, enough'. After a bit of playing around, I sorted a way to allow me to get this behavior to work in the context of Expect::Simple. Last Thursday I sent a patch off to the maintainer (Leon Brocard).

Basically, the patch adds the prompt-string and the quit-string to the results obtained from the test-code, before the results are passed on to Expect::Simple. This results in Expect::Simple returning the right stuff to the test-harness, and then, since the quit-string appeared following the 'next prompt', Expect::Simple cleans up and exits normally. I set things up so that you can call-out this behavior at will via a parameter passed into the Test::Expect::expect_run() routine.

/msg me if you need the work-around immediately, or wait until it gets incorporated formally into Test::Expect.

----
I Go Back to Sleep, Now.

OGB

  • Comment on Re: Interactive prompts inside a test harness