webfiend has asked for the wisdom of the Perl Monks concerning the following question:

I've got a Web site heavily spiked with tutorials and sample code. The tutorial programs are very simple, and the user interaction is not what you'd consider demanding.

Given a simple Parrot PIR program like this:

.sub 'main' :main .local string name .local string greeting .local pmc stdin stdin = getstdin name = stdin.'readline_interactive'("Please enter your name: ") greeting = "Hello, " . name greeting .= "!" say greeting .end

The sample usage is straightforward, but bothersome to double-check every time I update my Parrot install.

$ parrot code/example-01-06.pir
Please enter your name: Brian
Hello, Brian!

Manually verifying behavior after a language update has become tiresome. So I wrote some tests. They use IO::Pty::Easy to handle input and output.

use Modern::Perl; use IO::Pty::Easy; use Test::More tests => 3; my $pty = IO::Pty::Easy->new; ok $pty->spawn("parrot", "code/example-01-06.pir"); my $output = $pty->read(); is $output, "Please enter your name: "; $pty->write("Brian\n"); $output = $pty->read(); is $output, "Hello, Brian!\n"; $pty->close;

There's nothing wrong with this code - at least nothing that is obvious to me. I'm just wondering if there is a test approach or IO library preferred by the monks for testing lots of simple scripts of this nature.

Edit: Added the Parrot script being tested to hopefully improve the coherence of my late night post.