AnyEvent-Run
view release on metacpan - search on metacpan
view release on metacpan or search on metacpan
);
run(
name => 'arrayref cmd',
cmd => [ 'echo', 'test' ],
priority => 19,
);
run(
name => 'arrayref cmd + args',
cmd => [ 'echo' ],
args => [ 'test' ],
);
run(
name => 'stdin',
cmd => [ $^X, catfile($Bin, 'echo.plt') ],
stdin => 1,
);
run(
name => 'coderef',
cmd => sub { print "test\n" },
);
run(
name => 'exec class',
class => 'AERunTest',
priority => 19,
);
run(
name => 'exec class + method',
class => 'AERunTest',
method => 'stdin',
stdin => 1,
);
sub run {
my %args = @_;
my $testname = delete $args{name};
my $stdin = delete $args{stdin};
my $cv = AnyEvent->condvar;
my $handle = AnyEvent::Run->new(
%args,
on_read => sub {
my $handle = shift;
like( $handle->{rbuf}, qr/test(\r)?\n/, "$testname ok" );
$cv->send;
},
on_error => sub {
my ($handle, $fatal, $msg) = @_;
fail($msg);
$cv->send;
},
);
# Timeout in case of error
my $w = AnyEvent->timer( after => 2, cb => sub {
fail("$testname timed out");
$cv->send;
} );
if ( $stdin ) {
$handle->push_write("test\n");
}
$cv->recv;
}
view all matches for this distributionview release on metacpan - search on metacpan
( run in 1.406 second using v1.00-cache-2.02-grep-82fe00e-cpan-cec75d87357c )