diff --git a/lib/excon/test/plugin/server/exec.rb b/lib/excon/test/plugin/server/exec.rb index 7f86d157..f790d959 100644 --- a/lib/excon/test/plugin/server/exec.rb +++ b/lib/excon/test/plugin/server/exec.rb @@ -4,10 +4,13 @@ module Plugin module Server module Exec def start(app_str = app) - line = '' open_process(app_str) + process_stderr = "" + line = '' until line =~ /\Aready\Z/ line = error.gets + raise process_stderr if line.nil? + process_stderr << line fatal_time = elapsed_time > timeout if fatal_time msg = "executable #{app_str} has taken too long to start" diff --git a/lib/excon/test/plugin/server/puma.rb b/lib/excon/test/plugin/server/puma.rb index d87a8af6..69e11206 100644 --- a/lib/excon/test/plugin/server/puma.rb +++ b/lib/excon/test/plugin/server/puma.rb @@ -5,9 +5,12 @@ module Server module Puma def start(app_str = app, bind_uri = bind) open_process('puma', '-b', bind_uri.to_s, app_str) + process_stderr = "" line = '' until line =~ /Use Ctrl-C to stop/ line = read.gets + raise process_stderr if line.nil? + process_stderr << line fatal_time = elapsed_time > timeout raise 'puma server has taken too long to start' if fatal_time end diff --git a/lib/excon/test/plugin/server/unicorn.rb b/lib/excon/test/plugin/server/unicorn.rb index 990502d0..73a45e99 100644 --- a/lib/excon/test/plugin/server/unicorn.rb +++ b/lib/excon/test/plugin/server/unicorn.rb @@ -20,9 +20,12 @@ def start(app_str = app, bind_uri = bind) app_str ] open_process(*args) + process_stderr = '' line = '' until line =~ /worker\=0 ready/ line = error.gets + raise process_stderr if line.nil? + process_stderr << line fatal_time = elapsed_time > timeout raise 'unicorn server has taken too long to start' if fatal_time end diff --git a/lib/excon/test/plugin/server/webrick.rb b/lib/excon/test/plugin/server/webrick.rb index 19354d52..afe6c540 100644 --- a/lib/excon/test/plugin/server/webrick.rb +++ b/lib/excon/test/plugin/server/webrick.rb @@ -8,9 +8,12 @@ def start(app_str = app, bind_uri = bind) host = bind_uri.host.gsub(/[\[\]]/, '') port = bind_uri.port.to_s open_process('rackup', '-s', 'webrick', '--host', host, '--port', port, app_str) + process_stderr = "" line = '' until line =~ /HTTPServer#start/ line = error.gets + raise process_stderr if line.nil? + process_stderr << line fatal_time = elapsed_time > timeout raise 'webrick server has taken too long to start' if fatal_time end diff --git a/tests/test_helper.rb b/tests/test_helper.rb index 08bc4951..62dc6b2d 100644 --- a/tests/test_helper.rb +++ b/tests/test_helper.rb @@ -246,7 +246,11 @@ def rackup_path(*parts) def with_rackup(name, host="127.0.0.1") pid, w, r, e = launch_process("rackup", "-s", "webrick", "--host", host, rackup_path(name)) - until e.gets =~ /HTTPServer#start:/; end + process_stderr = "" + until (line = e.gets) =~ /HTTPServer#start:/ + raise process_stderr if line.nil? + process_stderr << line + end yield ensure cleanup_process(pid) @@ -271,7 +275,11 @@ def with_unicorn(name, listen='127.0.0.1:9292') unless RUBY_PLATFORM == 'java' unix_socket = listen.sub('unix://', '') if listen.start_with? 'unix://' pid, w, r, e = launch_process("unicorn", "--no-default-middleware","-l", listen, rackup_path(name)) - until e.gets =~ /worker=0 ready/; end + process_stderr = "" + until (line = e.gets) =~ /worker=0 ready/ + raise process_stderr if line.nil? + process_stderr << line + end else # need to find suitable server for jruby end @@ -290,7 +298,11 @@ def server_path(*parts) def with_server(name) pid, w, r, e = launch_process("ruby", server_path("#{name}.rb")) - until e.gets =~ /ready/; end + process_stderr = "" + until (line = e.gets) =~ /ready/ + raise process_stderr if line.nil? + process_stderr << line + end yield ensure cleanup_process(pid)