mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
test_utils.rb: dynamically chosen port number
* test/webrick/test_utils.rb (test_create_listeners): use dynamically chosen port number, not hardcoded port number. [ruby-core:67508] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49211 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
ae752cc546
commit
7c4d749d18
2 changed files with 26 additions and 4 deletions
|
@ -1,3 +1,9 @@
|
|||
Sun Jan 11 15:11:38 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* test/webrick/test_utils.rb (test_create_listeners): use
|
||||
dynamically chosen port number, not hardcoded port number.
|
||||
[ruby-core:67508]
|
||||
|
||||
Sat Jan 10 12:57:12 2015 SHIBATA Hiroshi <shibata.hiroshi@gmail.com>
|
||||
|
||||
* ext/zlib/zlib.c: fix document of method signatures.
|
||||
|
|
|
@ -59,10 +59,26 @@ class TestWEBrickUtils < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def test_create_listeners
|
||||
listeners = WEBrick::Utils.create_listeners("127.0.0.1", "9999")
|
||||
srv = listeners.first
|
||||
assert_equal true, srv.is_a?(TCPServer)
|
||||
assert_equal ["AF_INET", 9999, "127.0.0.1", "127.0.0.1"], srv.addr
|
||||
addr = listener_address(0)
|
||||
port = addr.slice!(1)
|
||||
assert_kind_of(Integer, port, "dynamically chosen port number")
|
||||
assert_equal(["AF_INET", "127.0.0.1", "127.0.0.1"], addr)
|
||||
|
||||
assert_equal(["AF_INET", port, "127.0.0.1", "127.0.0.1"],
|
||||
listener_address(port),
|
||||
"specific port number")
|
||||
|
||||
assert_equal(["AF_INET", port, "127.0.0.1", "127.0.0.1"],
|
||||
listener_address(port.to_s),
|
||||
"specific port number string")
|
||||
end
|
||||
|
||||
def listener_address(port)
|
||||
listeners = WEBrick::Utils.create_listeners("127.0.0.1", port)
|
||||
srv = listeners.first
|
||||
assert_kind_of TCPServer, srv
|
||||
srv.addr
|
||||
ensure
|
||||
listeners.each(&:close) if listeners
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue