On Sat, Feb 21, 2009 at 5:24 AM, Gabor Szabo <szab...@gmail.com> wrote: >>> I wonder if there are modules out there that already do this? >>> I could not find any that would fit my needs.
Test::Cmd? It's not built on Test::Builder but could be adapted/wrapped. It uses shell redirection to capture output, which should be OK as long as you don't need interactivity with the programs being run. I have something I wrote a long time ago for repetitive testing of a command line program. I've considered putting it on CPAN but never got around to writing much documentation for it. It works more or less like this: my $program = Test::CLI->new($path_to_program); $program->stdin( $input ); $program->runs_ok( @args ); $program->stdout_like( qr/$expected/ ); $stderr -> $program->stderr; # for custom examination Right now, it assumes the "program" is invoked via perl, but that could be stripped out. It also supports default arguments that are added to every run. So you might use it like this: my $interp = Test::CLI->new($path_to_interpreter, @default_params); for my $c (@cases) { $interp->stdin( slurp $c->{in_file} ); $interp->runs_ok( $c->{utility} ); $interp->stdout_like( $c->{stdout} ); $interp->stderr_is( $c->{stderr} ); } If you want, I'll stick it in some boilerplate and publish it to CPAN and github and then you're welcome to document it or improve it. Just let me know if that would be helpful. Or, if it would need a lot of adaptation for what you're looking to do, you're welcome to browse it and take whatever is useful. It's t/CLI.pm in the Pod::WikiDoc repo: http://github.com/dagolden/pod-wikidoc/ > Capture::Tiny is cute. More than cute -- it works and works pretty universally for all situations. I have a few more edge cases to code (e.g. if STDOUT or STDERR are closed before it starts capturing), but my goal is to have it replace the 20 or so other capturing modules out there. Then things like Test::Output can be re-written around it and will become much more powerful. -- David