about summary refs log tree commit
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2019-09-17 08:31:18 +0000
committerEric Wong <e@80x24.org>2019-09-17 08:31:39 +0000
commit7227d5882471e32858e460043e2dd69b4a926d4a (patch)
treecf55b94b53163bb4fd6025020f155b72d3418bc6
parent9a6fe0aac9ef23537af6221568c28aa11a81bbb5 (diff)
downloadpublic-inbox-7227d5882471e32858e460043e2dd69b4a926d4a.tar.gz
qspawn: remove return value from ->finish
We don't use the return value in real code since we do waitpid
asynchronously, now.  So simplify our runtime code at the cost
of making our test slighly more complex.
-rw-r--r--lib/PublicInbox/Qspawn.pm1
-rw-r--r--t/qspawn.t17
2 files changed, 11 insertions, 7 deletions
diff --git a/lib/PublicInbox/Qspawn.pm b/lib/PublicInbox/Qspawn.pm
index 54976b00..6b350f0f 100644
--- a/lib/PublicInbox/Qspawn.pm
+++ b/lib/PublicInbox/Qspawn.pm
@@ -141,7 +141,6 @@ sub finish ($;$) {
                         _do_spawn(@$next);
                 }
         }
-        $self->{err}; # may be meaningless if non-blocking
 }
 
 sub start {
diff --git a/t/qspawn.t b/t/qspawn.t
index ab6e3758..58c6febb 100644
--- a/t/qspawn.t
+++ b/t/qspawn.t
@@ -11,6 +11,12 @@ use_ok 'PublicInbox::Qspawn';
         is($res, "err\nout\n", 'captured stderr and stdout');
 }
 
+sub finish_err ($) {
+        my ($qsp) = @_;
+        $qsp->finish;
+        $qsp->{err};
+}
+
 my $limiter = PublicInbox::Qspawn::Limiter->new(1);
 {
         my $x = PublicInbox::Qspawn->new([qw(true)]);
@@ -18,7 +24,7 @@ my $limiter = PublicInbox::Qspawn::Limiter->new(1);
         $x->start($limiter, sub {
                 my ($rpipe) = @_;
                 is(0, sysread($rpipe, my $buf, 1), 'read zero bytes');
-                ok(!$x->finish, 'no error on finish');
+                ok(!finish_err($x), 'no error on finish');
                 $run = 1;
         });
         is($run, 1, 'callback ran alright');
@@ -30,8 +36,7 @@ my $limiter = PublicInbox::Qspawn::Limiter->new(1);
         $x->start($limiter, sub {
                 my ($rpipe) = @_;
                 is(0, sysread($rpipe, my $buf, 1), 'read zero bytes from false');
-                my $err = $x->finish;
-                ok($err, 'error on finish');
+                ok(finish_err($x), 'error on finish');
                 $run = 1;
         });
         is($run, 1, 'callback ran alright');
@@ -57,11 +62,11 @@ foreach my $cmd ([qw(sleep 1)], [qw(sh -c), 'sleep 1; false']) {
         } (0..2);
 
         if ($cmd->[-1] =~ /false\z/) {
-                ok($s->finish, 'got error on false after sleep');
+                ok(finish_err($s), 'got error on false after sleep');
         } else {
-                ok(!$s->finish, 'no error on sleep');
+                ok(!finish_err($s), 'no error on sleep');
         }
-        ok(!$_->[0]->finish, "true $_->[1] succeeded") foreach @t;
+        ok(!finish_err($_->[0]), "true $_->[1] succeeded") foreach @t;
         is_deeply([qw(sleep 0 1 2)], \@run, 'ran in order');
 }