unicorn Ruby/Rack server user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
blob 81ad82b03bb7436cfd2350fd31e85dd44113f2e6 815 bytes (raw)
name: test/unit/test_droplet.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
 
require 'test/unit'
require 'unicorn'

class TestDroplet < Test::Unit::TestCase
  def test_create_many_droplets
    now = Time.now.to_i
    (0..1024).each do |i|
      droplet = Unicorn::Worker.new(i)
      assert droplet.respond_to?(:tick)
      assert_equal 0, droplet.tick
      assert_equal(now, droplet.tick = now)
      assert_equal now, droplet.tick
      assert_equal(0, droplet.tick = 0)
      assert_equal 0, droplet.tick
    end
  end

  def test_shared_process
    droplet = Unicorn::Worker.new(0)
    _, status = Process.waitpid2(fork { droplet.tick += 1; exit!(0) })
    assert status.success?, status.inspect
    assert_equal 1, droplet.tick

    _, status = Process.waitpid2(fork { droplet.tick += 1; exit!(0) })
    assert status.success?, status.inspect
    assert_equal 2, droplet.tick
  end
end

debug log:

solving 81ad82b ...
found 81ad82b 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).