From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-5.4 required=3.0 tests=ALL_TRUSTED,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RP_MATCHES_RCVD shortcircuit=no autolearn=unavailable autolearn_force=no version=3.4.0 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 11F601FCB3 for ; Sun, 22 May 2016 20:57:36 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 1/5] t/spawn.t: additional tests for popen_rd Date: Sun, 22 May 2016 20:57:30 +0000 Message-Id: <20160522205734.12316-2-e@80x24.org> In-Reply-To: <20160522205734.12316-1-e@80x24.org> References: <20160522205734.12316-1-e@80x24.org> List-Id: We need to ensure $? is set properly for users. --- t/spawn.t | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/t/spawn.t b/t/spawn.t index d52b646..9e58f67 100644 --- 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();