summaryrefslogtreecommitdiff
path: root/test/webrick/test_server.rb
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-11-08 15:38:33 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-11-08 15:38:33 +0000
commit742bbbb01b310440a7672fabddd016226d20bee7 (patch)
tree735522e7c5325517e91b5bbb3932d1596a4ec2b7 /test/webrick/test_server.rb
parent8222432c9db1432995538a5d355d014c6fd1a0e9 (diff)
* test/webrick: Examine log and use assert_join_threads.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48318 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/webrick/test_server.rb')
-rw-r--r--test/webrick/test_server.rb30
1 files changed, 16 insertions, 14 deletions
diff --git a/test/webrick/test_server.rb b/test/webrick/test_server.rb
index 3f849a4..40afdb0 100644
--- a/test/webrick/test_server.rb
+++ b/test/webrick/test_server.rb
@@ -25,27 +25,29 @@ class TestWEBrickServer < Test::Unit::TestCase
def test_start_exception
stopped = 0
- config = {
- :StopCallback => Proc.new{ stopped += 1 },
- }
-
- assert_raises(SignalException) do
- TestWEBrick.start_server(Echo, config) { |server, addr, port, log|
- listener = server.listeners.first
- def listener.accept
- raise SignalException, 'SIGTERM' # simulate signal in main thread
- end
+ log = StringIO.new('')
+ logger = WEBrick::Log.new(log, WEBrick::BasicLog::WARN)
- Thread.pass while server.status != :Running
+ assert_raises(SignalException) do
+ listener = Object.new
+ def listener.to_io # IO.select invokes #to_io.
+ raise SignalException, 'SIGTERM' # simulate signal in main thread
+ end
- TCPSocket.open(addr, port) { |sock| sock << "foo\n" }
+ server = WEBrick::HTTPServer.new({
+ :BindAddress => "127.0.0.1", :Port => 0,
+ :StopCallback => Proc.new{ stopped += 1 },
+ :Logger => logger,
+ })
+ server.listeners[0].close
+ server.listeners[0] = listener
- Thread.pass until server.status == :Stop
- }
+ server.start
end
assert_equal(stopped, 1)
+ assert_match(/FATAL SignalException: SIGTERM/, log.string)
end
def test_callbacks