From 478d37da053f39608fa505991aa69bcff4ade998 Mon Sep 17 00:00:00 2001 From: naruse Date: Sat, 21 Jul 2012 19:07:28 +0000 Subject: Use 0 for webrick's port and get the actual port. [Bug #6766] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36491 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/net/http/test_http.rb | 10 +++++----- test/net/http/utils.rb | 5 ++++- 2 files changed, 9 insertions(+), 6 deletions(-) (limited to 'test/net/http') diff --git a/test/net/http/test_http.rb b/test/net/http/test_http.rb index 4867acf737..fc7bfa9806 100644 --- a/test/net/http/test_http.rb +++ b/test/net/http/test_http.rb @@ -616,7 +616,7 @@ end class TestNetHTTP_v1_2 < Test::Unit::TestCase CONFIG = { 'host' => '127.0.0.1', - 'port' => 10081, + 'port' => 0, 'proxy_host' => nil, 'proxy_port' => nil, } @@ -634,7 +634,7 @@ end class TestNetHTTP_v1_2_chunked < Test::Unit::TestCase CONFIG = { 'host' => '127.0.0.1', - 'port' => 10081, + 'port' => 0, 'proxy_host' => nil, 'proxy_port' => nil, 'chunked' => true, @@ -665,7 +665,7 @@ end class TestNetHTTPContinue < Test::Unit::TestCase CONFIG = { 'host' => '127.0.0.1', - 'port' => 10081, + 'port' => 0, 'proxy_host' => nil, 'proxy_port' => nil, 'chunked' => true, @@ -750,7 +750,7 @@ end class TestNetHTTPKeepAlive < Test::Unit::TestCase CONFIG = { 'host' => '127.0.0.1', - 'port' => 10081, + 'port' => 0, 'proxy_host' => nil, 'proxy_port' => nil, 'RequestTimeout' => 1, @@ -802,7 +802,7 @@ end class TestNetHTTPLocalBind < Test::Unit::TestCase CONFIG = { 'host' => 'localhost', - 'port' => 10081, + 'port' => 0, 'proxy_host' => nil, 'proxy_port' => nil, } diff --git a/test/net/http/utils.rb b/test/net/http/utils.rb index 07e0b9fa2d..9bea8f5474 100644 --- a/test/net/http/utils.rb +++ b/test/net/http/utils.rb @@ -19,7 +19,8 @@ module TestNetHTTPUtils end def config(key) - self.class::CONFIG[key] + @config ||= self.class::CONFIG + @config[key] end def logfile @@ -42,6 +43,7 @@ module TestNetHTTPUtils end def spawn_server + @config = self.class::CONFIG server_config = { :BindAddress => config('host'), :Port => config('port'), @@ -62,6 +64,7 @@ module TestNetHTTPUtils @server = WEBrick::HTTPServer.new(server_config) @server.mount('/', Servlet, config('chunked')) @server.start + @config['port'] = @server[:Port] if @config['port'] == 0 n_try_max = 5 begin TCPSocket.open(config('host'), config('port')).close -- cgit v1.2.3