From ad58f04833b6d9f6b0d01c5fc8adc61df6d088cc Mon Sep 17 00:00:00 2001 From: akr Date: Sun, 9 Nov 2014 14:01:20 +0000 Subject: * test/open-uri: Test server log in server thread. * test/webrick: Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48347 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/webrick/test_httpserver.rb | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'test/webrick/test_httpserver.rb') diff --git a/test/webrick/test_httpserver.rb b/test/webrick/test_httpserver.rb index eae77ec9ba..5cd4ba5866 100644 --- a/test/webrick/test_httpserver.rb +++ b/test/webrick/test_httpserver.rb @@ -230,7 +230,11 @@ class TestWEBrickHTTPServer < Test::Unit::TestCase :StopCallback => Proc.new{ stopped += 1 }, :RequestCallback => Proc.new{|req, res| requested0 += 1 }, } - TestWEBrick.start_httpserver(config){|server, addr, port, log| + log_tester = lambda {|log, access_log| + assert(log.find {|s| %r{ERROR `/' not found\.} =~ s }) + assert_equal([], log.reject {|s| %r{ERROR `/' not found\.} =~ s }) + } + TestWEBrick.start_httpserver(config, log_tester){|server, addr, port, log| vhost_config = { :ServerName => "myhostname", :BindAddress => addr, @@ -333,7 +337,11 @@ class TestWEBrickHTTPServer < Test::Unit::TestCase config = { :ServerName => "localhost" } - TestWEBrick.start_httpserver(config){|server, addr, port, log| + log_tester = lambda {|log, access_log| + assert_equal(1, log.length) + assert_match(/WARN Could not determine content-length of response body./, log[0]) + } + TestWEBrick.start_httpserver(config, log_tester){|server, addr, port, log| server.mount_proc("/", lambda { |req, res| r,w = IO.pipe # Test for not setting chunked... @@ -362,7 +370,12 @@ class TestWEBrickHTTPServer < Test::Unit::TestCase :ServerName => "localhost", :RequestHandler => Proc.new{|req, res| requested += 1 }, } - TestWEBrick.start_httpserver(config){|server, addr, port, log| + log_tester = lambda {|log, access_log| + assert_equal(2, log.length) + assert_match(/WARN :RequestHandler is deprecated, please use :RequestCallback/, log[0]) + assert_match(%r{ERROR `/' not found\.}, log[1]) + } + TestWEBrick.start_httpserver(config, log_tester){|server, addr, port, log| Thread.pass while server.status != :Running http = Net::HTTP.new(addr, port) -- cgit v1.2.3