From bd0d7d4448b8610c9ee97a36492e83313c9b5982 Mon Sep 17 00:00:00 2001 From: Ess Date: Tue, 31 Aug 2010 04:33:37 -0400 Subject: [PATCH] Added wait_for_socket_close definition and call in order to ensure that the app server we've started has exited. --- lib/webrat/selenium/application_servers/base.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/webrat/selenium/application_servers/base.rb b/lib/webrat/selenium/application_servers/base.rb index 10ecd54b..2307582d 100644 --- a/lib/webrat/selenium/application_servers/base.rb +++ b/lib/webrat/selenium/application_servers/base.rb @@ -15,6 +15,7 @@ def boot def stop_at_exit at_exit do stop + wait_for_socket_close end end @@ -34,6 +35,17 @@ def wait_for_socket rescue SocketError fail end + + def wait_for_socket_close + silence_stream(STDOUT) do + TCPSocket.wait_for_service_termination_with_timeout \ + :host => "0.0.0.0", + :port => Webrat.configuration.application_port.to_i, + :timeout => 30 + end + rescue SocketError + true + end def prepare_pid_file(file_path, pid_file_name) FileUtils.mkdir_p File.expand_path(file_path)