1
0
Fork 0
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:
MSP-Greg 2020-07-21 22:45:19 -05:00
parent df57cecce5
commit 27679d02f2
No known key found for this signature in database
GPG key ID: D688DA4A77D8FA18

View file

@ -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