mirror of
https://github.com/dkogan/feedgnuplot.git
synced 2025-05-06 06:21:16 +08:00
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
This commit is contained in:
parent
0863998848
commit
59625675f7
32
t/plots.t
32
t/plots.t
@ -15,9 +15,11 @@ BEGIN {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
use Test::More tests => 16;
|
use Test::More tests => 32;
|
||||||
use Test::Script::Run 'is_script_output';
|
|
||||||
use File::Temp 'tempfile';
|
use File::Temp 'tempfile';
|
||||||
|
use IPC::Run 'run';
|
||||||
|
use String::ShellQuote;
|
||||||
|
use File::Basename;
|
||||||
|
|
||||||
tryplot( testname => 'basic line plot',
|
tryplot( testname => 'basic line plot',
|
||||||
cmd => 'seq 5',
|
cmd => 'seq 5',
|
||||||
@ -820,24 +822,28 @@ tryplot( testname => 'Monotonicity check',
|
|||||||
|
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
sub tryplot
|
sub tryplot
|
||||||
{
|
{
|
||||||
my %args = @_;
|
my %args = @_;
|
||||||
|
|
||||||
my ($fh, $input_filename) = tempfile( UNLINK => 1);
|
|
||||||
open IN, '-|', $args{cmd};
|
|
||||||
print $fh <IN>;
|
|
||||||
close IN;
|
|
||||||
close $fh;
|
|
||||||
|
|
||||||
my @options = ('--exit',
|
my @options = ('--exit',
|
||||||
'--extracmds', 'unset grid',
|
'--extracmds', 'unset grid',
|
||||||
'--terminal', 'dumb 40,40',
|
'--terminal', 'dumb 40,40');
|
||||||
$input_filename);
|
|
||||||
|
|
||||||
unshift @options, @{$args{options}};
|
unshift @options, @{$args{options}};
|
||||||
|
|
||||||
is_script_output( 'feedgnuplot', \@options,
|
my $out = '';
|
||||||
[$args{refplot} =~ /(.*)\n/g], [],
|
my $err = '';
|
||||||
$args{testname});
|
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");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user