From 59625675f7ea2c0e3c7b9e15146740a3c271e6a4 Mon Sep 17 00:00:00 2001 From: Dima Kogan Date: Sat, 19 Oct 2013 21:31:23 -0700 Subject: [PATCH] test now uses IPC::Run directly instead of Test::Script::Run This is required for the streaming tests I'm about to write. Test::Script::Run doesn't know how to feed input from one process to another as the data comes in --- t/plots.t | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/t/plots.t b/t/plots.t index a5e26fe..63c8826 100644 --- a/t/plots.t +++ b/t/plots.t @@ -15,9 +15,11 @@ BEGIN { } } -use Test::More tests => 16; -use Test::Script::Run 'is_script_output'; +use Test::More tests => 32; use File::Temp 'tempfile'; +use IPC::Run 'run'; +use String::ShellQuote; +use File::Basename; tryplot( testname => 'basic line plot', cmd => 'seq 5', @@ -820,24 +822,28 @@ tryplot( testname => 'Monotonicity check', EOF + + + + sub tryplot { my %args = @_; - my ($fh, $input_filename) = tempfile( UNLINK => 1); - open IN, '-|', $args{cmd}; - print $fh ; - close IN; - close $fh; - my @options = ('--exit', '--extracmds', 'unset grid', - '--terminal', 'dumb 40,40', - $input_filename); + '--terminal', 'dumb 40,40'); unshift @options, @{$args{options}}; - is_script_output( 'feedgnuplot', \@options, - [$args{refplot} =~ /(.*)\n/g], [], - $args{testname}); + my $out = ''; + my $err = ''; + open IN, '-|', $args{cmd} or die "Couldn't open pipe to $args{cmd}"; + run [dirname($0) . "/../bin/feedgnuplot",, @options], + \*IN, \$out, \$err; + + note( "Running test '$args{testname}'. Running: $args{cmd} | feedgnuplot " . + shell_quote(@options)); + is($err, '', "$args{testname} stderr" ); + is($out, $args{refplot}, "$args{testname} stdout"); }