diff options
author | Pablo Carranza <pcarranza@gmail.com> | 2015-12-28 09:53:27 +0100 |
---|---|---|
committer | Pablo Carranza <pcarranza@gmail.com> | 2015-12-28 09:53:27 +0100 |
commit | 51180f1deadb2138b513b1950c9ad8782012398e (patch) | |
tree | 434cfb76ce13eea5307e643f997fb51f0ce7dceb | |
parent | cbe338c3c373cc7a26b6ca153d1c53ca187489eb (diff) | |
download | bundler-51180f1deadb2138b513b1950c9ad8782012398e.tar.gz |
Use linear search to find an unused port
-rw-r--r-- | spec/support/helpers.rb | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/spec/support/helpers.rb b/spec/support/helpers.rb index 324e52d2d0..09ef6e2945 100644 --- a/spec/support/helpers.rb +++ b/spec/support/helpers.rb @@ -430,9 +430,12 @@ module Spec end def find_unused_port - tcp_server = TCPServer.new("127.0.0.1", 0) # Use any available ephemeral port - port = tcp_server.addr[1] - tcp_server.close + port = 21_453 + begin + port += 1 while TCPSocket.new("127.0.0.1", port) + rescue + false + end port end end |