Skip to content

Commit

Permalink
retry failing integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rkh committed Mar 18, 2012
1 parent b5bbb27 commit b882ab3
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions test/integration_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,17 @@ def thin?
def warnings
log.scan(%r[(?:\(eval|lib/sinatra).*warning:.*$])
end

def run_test(target, &block)
retries ||= 3
target.server = self
run unless alive?
target.instance_eval(&block)
rescue Exception => error
retries -= 1
kill
retries < 0 ? retry : raise(error)
end
end

if RUBY_ENGINE == "jruby"
Expand Down Expand Up @@ -188,16 +199,7 @@ def kill
def it(message, &block)
Server.each do |server|
next unless server.installed?
super "with #{server.name}: #{message}" do
self.server = server
server.run unless server.alive?
begin
instance_eval(&block)
rescue Exception => error
server.kill
raise error
end
end
super("with #{server.name}: #{message}") { server.run_test(self, &block) }
end
end

Expand Down

0 comments on commit b882ab3

Please sign in to comment.