test/test_wbuf.rb in yahns-1.12.5 vs test/test_wbuf.rb in yahns-1.13.0

- old
+ new

@@ -5,12 +5,19 @@ require 'timeout' class TestWbuf < Testcase ENV["N"].to_i > 1 and parallelize_me! + def setup + skip 'sendfile missing' unless IO.instance_methods.include?(:sendfile) + end + class KgioUS < UNIXSocket include Kgio::SocketMethods + def self.output_buffer_tmpdir + Dir.tmpdir + end end def socketpair KgioUS.pair.each { |io| io.close_on_exec = true } end @@ -18,12 +25,12 @@ def test_wbuf skip "sendfile not Linux-compatible" if RUBY_PLATFORM !~ /linux/ buf = "*" * (16384 * 2) nr = 1000 [ true, false ].each do |persist| - wbuf = Yahns::Wbuf.new([], persist, Dir.tmpdir, :wait_writable) - assert_equal :wait_writable, wbuf.busy + wbuf = Yahns::Wbuf.new([], persist) + assert_equal false, wbuf.busy a, b = socketpair assert_nil wbuf.wbuf_write(a, "HIHI") assert_equal "HIHI", b.read(4) nr.times { wbuf.wbuf_write(a, buf) } assert_equal :wait_writable, wbuf.wbuf_flush(a) @@ -69,11 +76,11 @@ a.write_nonblock(buf) rescue Errno::EAGAIN break end while true end - wbuf = Yahns::Wbuf.new([], true, Dir.tmpdir, :wait_writable) + wbuf = Yahns::Wbuf.new([], true) rv1 = wbuf.wbuf_write(a, buf) rv2 = wbuf.wbuf_flush(a) case rv1 when nil @@ -102,10 +109,10 @@ end def test_wbuf_flush_close pipe = cloexec_pipe persist = true - wbuf = Yahns::Wbuf.new(pipe[0], persist, Dir.tmpdir, :wait_writable) + wbuf = Yahns::Wbuf.new(pipe[0], persist) refute wbuf.respond_to?(:close) # we don't want this for HttpResponse body sp = socketpair rv = nil buf = ("*" * 16384) << "\n"