Skip to content

Commit

Permalink
a few more subprocess tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Aug 27, 2016
1 parent eddf9be commit a89a2d0
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions t/mojo/subprocess.t
Expand Up @@ -25,6 +25,21 @@ Mojo::IOLoop->start;
ok !$fail, 'no error';
is $result, 0 . $subprocess->pid . ('x' x 100000), 'right result';

# Custom event loop
($fail, $result) = ();
my $loop = Mojo::IOLoop->new;
$loop->subprocess(
sub {''},
sub {
my ($subprocess, $err, @results) = @_;
$fail = $err;
$result = \@results;
}
);
$loop->start;
ok !$fail, 'no error';
is_deeply $result, [''], 'right structure';

# Multiple return values
($fail, $result) = ();
$subprocess = Mojo::IOLoop::Subprocess->new;
Expand Down Expand Up @@ -77,6 +92,20 @@ Mojo::IOLoop->delay(
ok !$fail, 'no error';
is_deeply $result, [1, 2], 'right structure';

# No result
($fail, $result) = ();
Mojo::IOLoop::Subprocess->new->run(
sub { exit 0 },
sub {
my ($subprocess, $err, @results) = @_;
$fail = $err;
$result = \@results;
}
);
Mojo::IOLoop->start;
ok !$fail, 'no error';
is_deeply $result, [], 'right structure';

# Non-zero exit status
$fail = undef;
Mojo::IOLoop::Subprocess->new->run(
Expand Down

0 comments on commit a89a2d0

Please sign in to comment.