From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-3.9 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 151F31F885 for ; Sun, 26 Jan 2020 05:33:34 +0000 (UTC) From: Eric Wong To: unicorn-public@yhbt.net Subject: [PATCH 3/3] test_upload: use spawn to simplify redirects Date: Sun, 26 Jan 2020 05:33:33 +0000 Message-Id: <20200126053333.28163-4-bofh@yhbt.net> In-Reply-To: <20200126053333.28163-1-bofh@yhbt.net> References: <20200126053333.28163-1-bofh@yhbt.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: We can start using Ruby 1.9 APIs, nowadays (right?) --- test/unit/test_upload.rb | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/test/unit/test_upload.rb b/test/unit/test_upload.rb index 5de02e4..8d90e50 100644 --- a/test/unit/test_upload.rb +++ b/test/unit/test_upload.rb @@ -236,15 +236,10 @@ def test_chunked_upload_via_curl resp = Tempfile.new('resp') resp.sync = true - rd, wr = IO.pipe - wr.sync = rd.sync = true - pid = fork { - STDIN.reopen(rd) - rd.close - wr.close - STDOUT.reopen(resp) - exec cmd - } + rd, wr = IO.pipe.each do |io| + io.sync = io.close_on_exec = true + end + pid = spawn(*cmd, { 0 => rd, 1 => resp }) rd.close tmp.rewind