[Pdx-pm] Testing STDIN

Joshua Keroes joshua at keroes.com
Fri Aug 3 17:48:18 PDT 2007

I have a mock router class that prints to STDOUT and reads from STDIN.
I'm a little unsure about how to test this.

The mock router is a state machine (implemented with Dave Wheeler's
FSA::Rules). Each state typically prints a prompt, e.g.


and waits for the user to type something, e.g.

    chomp( my $in = <STDIN> );

And of course, that <STDIN> will block while it waits for user-input.
Seems like I need to fork the router process off into one process and
connect it to another process that will pretend to be a fake user.

Is there a cleaner way to test this?


More information about the Pdx-pm-list mailing list