about summary refs log tree commit homepage
path: root/test/test_helper.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_helper.rb')
-rw-r--r--test/test_helper.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/test/test_helper.rb b/test/test_helper.rb
index d3bf46c..3a3e42f 100644
--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -104,6 +104,12 @@ def unused_port(addr = '127.0.0.1')
   begin
     begin
       port = base + rand(32768 - base)
+      if addr == Unicorn::Const::DEFAULT_HOST
+        while port == Unicorn::Const::DEFAULT_PORT
+          port = base + rand(32768 - base)
+        end
+      end
+
       sock = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM, 0)
       sock.bind(Socket.pack_sockaddr_in(port, addr))
       sock.listen(5)