summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-03-10 11:05:21 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-03-10 11:05:21 +0000
commitab0a64e1c87d8fd9d0a6ee8bb6bc084d0a6f482b (patch)
tree7c827ee68f0bafd6c3712d069809f438e3d979ca /test
parentacc17bfc0f408846f07dff0c1f6f3d0f64390b81 (diff)
* lib/webrick/server.rb: Invoke setup_shutdown_pipe in start method
instead of listen method. [ruby-core:68476] [Bug #10956] Reported by Shintaro Kojima. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49917 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/webrick/test_server.rb28
1 files changed, 27 insertions, 1 deletions
diff --git a/test/webrick/test_server.rb b/test/webrick/test_server.rb
index 043d439cb7c..ea237c6166b 100644
--- a/test/webrick/test_server.rb
+++ b/test/webrick/test_server.rb
@@ -97,7 +97,7 @@ class TestWEBrickServer < Test::Unit::TestCase
end
end
- def test_restart
+ def test_restart_after_shutdown
address = '127.0.0.1'
port = 0
log = []
@@ -128,4 +128,30 @@ class TestWEBrickServer < Test::Unit::TestCase
assert_join_threads([client_thread, server_thread])
assert_equal([], log)
end
+
+ def test_restart_after_stop
+ log = Object.new
+ class << log
+ include Test::Unit::Assertions
+ def <<(msg)
+ flunk "unexpected log: #{msg.inspect}"
+ end
+ end
+ warn_flunk = WEBrick::Log.new(log, WEBrick::BasicLog::WARN)
+ server = WEBrick::HTTPServer.new(
+ :BindAddress => '0.0.0.0',
+ :Port => 0,
+ :Logger => warn_flunk)
+ 2.times {
+ server_thread = Thread.start {
+ server.start
+ }
+ client_thread = Thread.start {
+ sleep 0.1 until server.status == :Running || !server_thread.status
+ server.stop
+ sleep 0.1 until server.status == :Stop || !server_thread.status
+ }
+ assert_join_threads([client_thread, server_thread])
+ }
+ end
end