Skip to content

Commit

Permalink
Fix shutdown_pipe test issue
Browse files Browse the repository at this point in the history
  • Loading branch information
wishdev authored and jeremyevans committed Jul 26, 2020
1 parent 86ed621 commit 9676704
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions test/webrick/test_server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -162,15 +162,26 @@ def <<(msg)
end

def test_shutdown_pipe
pipe = IO.pipe
server = WEBrick::GenericServer.new(
:ShutdownPipe => pipe,
:BindAddress => '0.0.0.0',
:Port => 0,
:Logger => WEBrick::Log.new([], WEBrick::BasicLog::WARN))
server_thread = Thread.start { server.start }
pipe.last.puts('')
assert_join_threads([server_thread])
loop_count = 0
server_threads = []
loop do
loop_count += 1
break if loop_count == 11

pipe = IO.pipe
server = WEBrick::GenericServer.new(
:ShutdownPipe => pipe,
:BindAddress => '0.0.0.0',
:Port => 0,
:Logger => WEBrick::Log.new([], WEBrick::BasicLog::WARN))
server_threads << Thread.start { server.start }
sleep 0.1 until server.status == :Running || !server_threads.last.status
if server_threads.last.status
pipe.last.puts('')
break
end
end
assert_join_threads(server_threads)
end

def test_port_numbers
Expand Down

0 comments on commit 9676704

Please sign in to comment.