[Milan-pm] How to test Output when using IPC::Open3
marcos rebelo
oleber at gmail.com
Sat Aug 28 00:45:43 PDT 2010
I'm having a more or less complicated code, that was simplified to this.
use strict;
use warnings;
use IPC::Open3;
use IO::Handle;
use Test::More;
use Test::Trap;
sub shell_run {
my ($stdin, $stdout, $stderr) = map {IO::Handle->new} (0..2);
print "YYYY";
open3($stdin, $stdout, $stderr, @_);
foreach my $line (<$stdout>, <$stderr>) {
print "read: $line";
}
print "ZZZZ";
}
trap {shell_run('perl', '-E', 'print "TEXT IN"')};
#is( $trap->stdout, "YYYYZZZZ");
is( $trap->stdout, "YYYYTEXT INZZZZ");
done_testing();
I would expect to have the test 'is( $trap->stdout, "YYYYTEXT
INZZZZ");' executing ok, instead of that I have the test 'is(
$trap->stdout, "YYYYZZZZ");'.
I need to test the output inside the loop in there, I have tried allot
of solution but I just don't get it
How do I do it?
Thanks for your help
Best Regards
Marcos Rebelo
--
Marcos Rebelo
http://oleber.freehostia.com
Milan Perl Mongers leader http://milan.pm.org
Webmaster of http://sites.google.com/site/oleberperlrecipes/
More information about the Milan-pm
mailing list