Skip to content

Commit

Permalink
Make test stable by adding simple tick delayer
Browse files Browse the repository at this point in the history
  • Loading branch information
raggi committed Oct 1, 2009
1 parent e48bbb1 commit 791d50a
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion tests/test_server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ def setup
def job(&blk)
EM.next_tick(&blk)
end

def in_ticks(n = 3, &b)
if n == 0
yield
else
job { in_ticks(n - 1, &b) }
end
end

# The block passed to go here will be added as a next_tick in order to
# preserve execution order for any predefined jobs in the next_tick queue.
Expand Down Expand Up @@ -84,7 +92,9 @@ def test_run

def test_stop
server = EM::Server.new(localhost, port, EM::Connection).listen.stop
go { EM.connect(localhost, port, UnbindStopper) }
# We have to belay this a few ticks to allow the machine to asynchronously
# complete the closing of the listen socket
go { in_ticks(5) { EM.connect(localhost, port, UnbindStopper) } }
end

class Aggregator
Expand Down

0 comments on commit 791d50a

Please sign in to comment.