|
You are looking at a very old, but free version of the course. If you are interesed the most recent version, check it out on the Perl Maven site. 7.21. Capturing both STDOUT and STDERR using IPC::Run3Example 7-11. examples/io/capture_ipc.pl #!/usr/bin/perl -w
use strict;
use Test::More tests => 2;
use IPC::Run3;
my $app = "./examples/io/application.pl";
my @in = ('10', '21', 'hello', '3x');
my $in = join "\n", @in;
my @expected_out = ('20', '42');
my @expected_err = (
"The input 'hello' contains no numeric values",
"The input '3x' contains no numeric values",
);
{
my $out;
my $err;
run3 [$app], \$in, \$out, \$err;
my $expected_out = join("\n", @expected_out) . "\n";
is($out, $expected_out, "IPC Output");
my $expected_err = join("\n", @expected_err) . "\n";
is($err, $expected_err, "IPC Error");
}
|