ruby-changes:24440
From: naruse <ko1@a...>
Date: Sun, 22 Jul 2012 04:07:50 +0900 (JST)
Subject: [ruby-changes:24440] naruse:r36491 (trunk): Use 0 for webrick's port and get the actual port. [Bug #6766]
naruse 2012-07-22 04:07:28 +0900 (Sun, 22 Jul 2012) New Revision: 36491 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=36491 Log: Use 0 for webrick's port and get the actual port. [Bug #6766] Modified files: trunk/test/net/http/test_http.rb trunk/test/net/http/utils.rb Index: test/net/http/test_http.rb =================================================================== --- test/net/http/test_http.rb (revision 36490) +++ test/net/http/test_http.rb (revision 36491) @@ -616,7 +616,7 @@ 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 @@ 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 @@ 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 @@ 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 @@ class TestNetHTTPLocalBind < Test::Unit::TestCase CONFIG = { 'host' => 'localhost', - 'port' => 10081, + 'port' => 0, 'proxy_host' => nil, 'proxy_port' => nil, } Index: test/net/http/utils.rb =================================================================== --- test/net/http/utils.rb (revision 36490) +++ test/net/http/utils.rb (revision 36491) @@ -19,7 +19,8 @@ end def config(key) - self.class::CONFIG[key] + @config ||= self.class::CONFIG + @config[key] end def logfile @@ -42,6 +43,7 @@ end def spawn_server + @config = self.class::CONFIG server_config = { :BindAddress => config('host'), :Port => config('port'), @@ -62,6 +64,7 @@ @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 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/