mirror of
https://github.com/lostisland/faraday.git
synced 2025-10-16 00:03:37 -04:00
script/test: avoid using Timeout while waiting for server
This commit is contained in:
parent
7f9df7a08b
commit
924cf57e7c
14
script/test
14
script/test
@ -42,6 +42,8 @@ end
|
|||||||
|
|
||||||
server = nil
|
server = nil
|
||||||
|
|
||||||
|
Thread.abort_on_exception = true
|
||||||
|
|
||||||
# start test server in a separate thread
|
# start test server in a separate thread
|
||||||
thread = Thread.new do
|
thread = Thread.new do
|
||||||
old_verbose, $VERBOSE = $VERBOSE, nil
|
old_verbose, $VERBOSE = $VERBOSE, nil
|
||||||
@ -78,7 +80,7 @@ end
|
|||||||
|
|
||||||
require 'net/http'
|
require 'net/http'
|
||||||
conn = Net::HTTP.new host, port
|
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
|
# test if test server is accepting requests
|
||||||
responsive = lambda { |path|
|
responsive = lambda { |path|
|
||||||
@ -90,11 +92,13 @@ responsive = lambda { |path|
|
|||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
require 'timeout'
|
server_pings = 0
|
||||||
Timeout.timeout 40 do
|
begin
|
||||||
# block until test server is ready
|
# block until test server is ready
|
||||||
thread.join 0.05 until responsive.call('/echo')
|
thread.join 0.05
|
||||||
end
|
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}"
|
ENV['LIVE'] = "http://#{host}:#{port}"
|
||||||
ok = system 'ruby', '-Ilib:test', '-S', 'testrb', *test_files
|
ok = system 'ruby', '-Ilib:test', '-S', 'testrb', *test_files
|
||||||
|
Loading…
x
Reference in New Issue
Block a user