From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 25FF61F698 for ; Thu, 29 Dec 2022 00:26:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yhbt.net; s=selector1; t=1672273605; bh=D6XQPFGkdOF2NB0C7Dkbcuqz/4Wau8Bnm+d7Wk51y2Y=; h=From:To:Subject:Date:From; b=jG9yc+VPkaUy6gEqbPAyaS0ACaEMjXwhlQQEBgXT2bIt2mZEjR7uOhimWEbPkEGgG 9795TNPdw92ilTL01bhIvpgXV0r1dOeSHJVnkdM9NFZFhcRsY6ac2KG5dDGp4GxdOr oH0a6plTSF3oa3gcgLfYS0s2rKFgchYkM/+kzYSU= From: Eric Wong To: yahns-public@yhbt.net Subject: [PATCH] tests: use IO.pipe directly Date: Thu, 29 Dec 2022 00:26:45 +0000 Message-Id: <20221229002645.2326431-1-bofh@yhbt.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: No need for a wrapper, since we've been Ruby 2.0+ for a while, now. --- test/helper.rb | 4 ---- test/test_bin.rb | 2 +- test/test_server.rb | 2 +- test/test_wbuf.rb | 6 +++--- 4 files changed, 5 insertions(+), 9 deletions(-) diff --git a/test/helper.rb b/test/helper.rb index f9370a4..c4403dd 100644 --- a/test/helper.rb +++ b/test/helper.rb @@ -124,10 +124,6 @@ def nread end end if ! IO.method_defined?(:nread) && RUBY_PLATFORM =~ /linux/ -def cloexec_pipe - IO.pipe -end - def require_exec(cmd) ENV["PATH"].split(/:/).each do |path| return true if File.executable?("#{path}/#{cmd}") diff --git a/test/test_bin.rb b/test/test_bin.rb index fc85992..e7c55ad 100644 --- a/test/test_bin.rb +++ b/test/test_bin.rb @@ -76,7 +76,7 @@ def bin_daemon(worker, inherit) cfg.puts " listen ENV['YAHNS_TEST_LISTEN']" cfg.puts "end" @cmd.concat(%W(-D -c #{cfg.path})) - addr = cloexec_pipe + addr = IO.pipe pid = xfork do opts = { close_others: true } addr[0].close diff --git a/test/test_server.rb b/test/test_server.rb index 75e1857..29803fb 100644 --- a/test/test_server.rb +++ b/test/test_server.rb @@ -185,7 +185,7 @@ def test_check_client_connection msgs = %w(ZZ zz) err = @err cfg = Yahns::Config.new - bpipe = cloexec_pipe + bpipe = IO.pipe cfg.instance_eval do ru = lambda { |e| case e['PATH_INFO'] diff --git a/test/test_wbuf.rb b/test/test_wbuf.rb index 0135958..101f6c5 100644 --- a/test/test_wbuf.rb +++ b/test/test_wbuf.rb @@ -34,7 +34,7 @@ def test_wbuf assert_equal "HIHI", b.read(4) nr.times { wbuf.wbuf_write(a, buf) } assert_equal :wait_writable, wbuf.wbuf_flush(a) - done = cloexec_pipe + done = IO.pipe thr = Thread.new do rv = [] until rv[-1] == persist @@ -109,7 +109,7 @@ def test_wbuf_blocked end def test_wbuf_flush_close - pipe = cloexec_pipe + pipe = IO.pipe persist = true wbuf = Yahns::Wbuf.new(pipe[0], persist) refute wbuf.respond_to?(:close) # we don't want this for HttpResponse body @@ -126,7 +126,7 @@ def test_wbuf_flush_close assert_equal thr, thr.join(5) assert_equal :wait_writable, rv - done = cloexec_pipe + done = IO.pipe thr = Thread.new do rv = [] until rv[-1] == persist