From 924cf57e7cc32d102eabe65c2c8e1a9f62f476cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohnic=CC=81?= Date: Thu, 16 Aug 2012 12:44:02 +0200 Subject: [PATCH] script/test: avoid using Timeout while waiting for server --- script/test | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/script/test b/script/test index b33976ef..a04712cd 100755 --- a/script/test +++ b/script/test @@ -42,6 +42,8 @@ end server = nil +Thread.abort_on_exception = true + # start test server in a separate thread thread = Thread.new do old_verbose, $VERBOSE = $VERBOSE, nil @@ -78,7 +80,7 @@ end require 'net/http' conn = Net::HTTP.new host, port -conn.open_timeout = conn.read_timeout = 0.05 +conn.open_timeout = conn.read_timeout = 0.1 # test if test server is accepting requests responsive = lambda { |path| @@ -90,11 +92,13 @@ responsive = lambda { |path| end } -require 'timeout' -Timeout.timeout 40 do +server_pings = 0 +begin # block until test server is ready - thread.join 0.05 until responsive.call('/echo') -end + thread.join 0.05 + server_pings += 1 + abort "test server didn't manage to start" if server_pings >= 50 +end until responsive.call('/echo') ENV['LIVE'] = "http://#{host}:#{port}" ok = system 'ruby', '-Ilib:test', '-S', 'testrb', *test_files