yahns Ruby server user/dev discussion
 help / color / mirror / code / Atom feed
* [PATCH] tests: use IO.pipe directly
@ 2022-12-29  0:26 Eric Wong
  0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2022-12-29  0:26 UTC (permalink / raw)
  To: yahns-public

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

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2022-12-29  0:26 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-29  0:26 [PATCH] tests: use IO.pipe directly Eric Wong

Code repositories for project(s) associated with this public inbox

	https://yhbt.net/yahns.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).