unicorn Ruby/Rack server user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
blob 0995de2ae08f9d0e2f8c800b34bd0d75d4b9afa3 1028 bytes (raw)
name: test/unit/test_waiter.rb 	 # note: path name is non-authoritative(*)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
 
require 'test/unit'
require 'unicorn'
require 'unicorn/select_waiter'
class TestSelectWaiter < Test::Unit::TestCase

  def test_select_timeout # n.b. this is level-triggered
    sw = Unicorn::SelectWaiter.new
    IO.pipe do |r,w|
      sw.get_readers(ready = [], [r], 0)
      assert_equal [], ready
      w.syswrite '.'
      sw.get_readers(ready, [r], 1000)
      assert_equal [r], ready
      sw.get_readers(ready, [r], 0)
      assert_equal [r], ready
    end
  end

  def test_linux # ugh, also level-triggered, unlikely to change
    IO.pipe do |r,w|
      wtr = Unicorn::Waiter.prep_readers([r])
      wtr.get_readers(ready = [], [r], 0)
      assert_equal [], ready
      w.syswrite '.'
      wtr.get_readers(ready = [], [r], 1000)
      assert_equal [r], ready
      wtr.get_readers(ready = [], [r], 1000)
      assert_equal [r], ready, 'still ready (level-triggered :<)'
      assert_nil wtr.close
    end
  rescue SystemCallError => e
    warn "#{e.message} (#{e.class})"
  end if Unicorn.const_defined?(:Waiter)
end

debug log:

solving 0995de2 ...
found 0995de2 in https://yhbt.net/unicorn.git/

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

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

	https://yhbt.net/unicorn.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).