mirror of
https://github.com/puma/puma.git
synced 2022-11-09 13:48:40 -05:00
test/helper.rb - wrap Timeout around only test method
This commit is contained in:
parent
df57cecce5
commit
27679d02f2
1 changed files with 21 additions and 5 deletions
|
@ -58,11 +58,27 @@ module TimeoutEveryTestCase
|
|||
class TestTookTooLong < Timeout::Error
|
||||
end
|
||||
|
||||
def time_it
|
||||
t0 = Minitest.clock_time
|
||||
::Timeout.timeout(RUBY_ENGINE == 'ruby' ? 60 : 120, TestTookTooLong) { yield }
|
||||
ensure
|
||||
self.time = Minitest.clock_time - t0
|
||||
def run
|
||||
with_info_handler do
|
||||
time_it do
|
||||
capture_exceptions do
|
||||
before_setup; setup; after_setup
|
||||
|
||||
# wrap timeout around test method only
|
||||
::Timeout.timeout(RUBY_ENGINE == 'ruby' ? 60 : 120, TestTookTooLong) {
|
||||
self.send self.name
|
||||
}
|
||||
end
|
||||
|
||||
Minitest::Test::TEARDOWN_METHODS.each do |hook|
|
||||
capture_exceptions do
|
||||
self.send hook
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Minitest::Result.from self # per contract
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue