Browse files

don't let integration tests block indefinitely

  • Loading branch information...
1 parent df317cf commit fbdb25bb0de8f39c110f51cd7c7f05407bb41653 @rkh rkh committed Mar 18, 2012
Showing with 3 additions and 3 deletions.
  1. +3 −2 test/integration_helper.rb
  2. +0 −1 test/integration_test.rb
View
5 test/integration_helper.rb
@@ -2,6 +2,7 @@
require 'rbconfig'
require 'open-uri'
require 'net/http'
+require 'timeout'
module IntegrationHelper
class BaseServer
@@ -65,7 +66,7 @@ def ping(timeout = 30)
def alive?
3.times { get('/ping') }
true
- rescue Errno::ECONNREFUSED, Errno::ECONNRESET, EOFError, SystemCallError, OpenURI::HTTPError => error
+ rescue Errno::ECONNREFUSED, Errno::ECONNRESET, EOFError, SystemCallError, OpenURI::HTTPError, Timeout::Error => error
false
end
@@ -79,7 +80,7 @@ def get_stream(url = "/stream", &block)
end
def get(url)
- open("http://127.0.0.1:#{port}#{url}").read
+ Timeout.timeout(1) { open("http://127.0.0.1:#{port}#{url}").read }
end
def log
View
1 test/integration_test.rb
@@ -1,6 +1,5 @@
require File.expand_path('../helper', __FILE__)
require File.expand_path('../integration_helper', __FILE__)
-require 'timeout'
# These tests start a real server and talk to it over TCP.
# Every test runs with every detected server.

0 comments on commit fbdb25b

Please sign in to comment.