summaryrefslogtreecommitdiff
path: root/test/webrick/utils.rb
diff options
context:
space:
mode:
authormame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-10-29 11:48:35 +0000
committermame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-10-29 11:48:35 +0000
commit224471fd572c1818e99c66f756ce398745885398 (patch)
tree8f02ccee39290f8aa03b81c401d801ba4ac0d601 /test/webrick/utils.rb
parent3056933cc0b7c1d68ddda1a143bfa298a92f4a0c (diff)
* test/webrick/utils.rb (start_server): provide a reference to log of
webrick. * test/webrick/test_httpproxy.rb, test/webrick/test_httpauth.rb, test/webrick/test_cgi.rb, test/webrick/test_httpserver.rb, test/webrick/test_server.rb, test/webrick/test_filehandler.rb: use webrick log as an assertion message. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20023 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/webrick/utils.rb')
-rw-r--r--test/webrick/utils.rb13
1 files changed, 10 insertions, 3 deletions
diff --git a/test/webrick/utils.rb b/test/webrick/utils.rb
index 39cadcf..82df9cd 100644
--- a/test/webrick/utils.rb
+++ b/test/webrick/utils.rb
@@ -27,23 +27,30 @@ module TestWEBrick
module_function
def start_server(klass, config={}, &block)
+ log_string = ""
+ logger = Object.new
+ logger.instance_eval do
+ define_singleton_method(:<<) {|msg| log_string << msg }
+ end
+ log = proc { "webrick log start:\n" + log_string.gsub(/^/, " ").chomp + "\nwebrick log end" }
server = klass.new({
:BindAddress => "127.0.0.1", :Port => 0,
:ShutdownSocketWithoutClose =>true,
:ServerType => Thread,
- :Logger => WEBrick::Log.new(NullWriter),
- :AccessLog => [[NullWriter, ""]]
+ :Logger => WEBrick::Log.new(logger),
+ :AccessLog => [[logger, ""]]
}.update(config))
begin
server.start
addr = server.listeners[0].addr
- block.yield([server, addr[3], addr[1]])
+ block.yield([server, addr[3], addr[1], log])
ensure
server.shutdown
until server.status == :Stop
sleep 0.1
end
end
+ log_string
end
def start_httpserver(config={}, &block)