]> Sergey Matveev's repositories - public-inbox.git/commitdiff
t/spawn.t: additional tests for popen_rd
authorEric Wong <e@80x24.org>
Sun, 22 May 2016 07:49:04 +0000 (07:49 +0000)
committerEric Wong <e@80x24.org>
Sun, 22 May 2016 07:52:50 +0000 (07:52 +0000)
We need to ensure $? is set properly for users.

t/spawn.t

index d52b646562c45d38704869e2022cc129c931db17..9e58f675fe2a8fd140e7dd96982d1e639cbd674b 100644 (file)
--- a/t/spawn.t
+++ b/t/spawn.t
@@ -70,6 +70,15 @@ use PublicInbox::Spawn qw(which spawn popen_rd);
        is(sysread($fh, $buf, 6), 6, 'sysread got 6 bytes');
        is($buf, "hello\n", 'tied gets works');
        is(sysread($fh, $buf, 6), 0, 'sysread got EOF');
+       $? = 1;
+       close $fh;
+       is($?, 0, '$? set properly');
+}
+
+{
+       my $fh = popen_rd([qw(false)]);
+       close $fh;
+       isnt($?, 0, '$? set properly: '.$?);
 }
 
 {
@@ -80,6 +89,7 @@ use PublicInbox::Spawn qw(which spawn popen_rd);
           'sysread returned quickly with EAGAIN');
        is(kill(15, $pid), 1, 'child process killed early');
        is(waitpid($pid, 0), $pid, 'child process reapable');
+       isnt($?, 0, '$? set properly: '.$?);
 }
 
 done_testing();