Merge pull request #9004 from MikeMcQuaid/fix-timeout-exit-retry

spec_helper: fix Timeout::Error/SystemExit handling.
This commit is contained in:
Mike McQuaid 2020-10-29 11:41:32 +00:00 committed by GitHub
commit 63fc64a050
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -189,20 +189,15 @@ RSpec.configure do |config|
end end
begin begin
timeout = example.metadata.fetch(:timeout, 120) timeout = example.metadata.fetch(:timeout, 60)
inner_timeout = nil
Timeout.timeout(timeout) do Timeout.timeout(timeout) do
example.run example.run
rescue Timeout::Error => e
inner_timeout = e
end end
rescue Timeout::Error rescue Timeout::Error => e
raise "Example exceeded maximum runtime of #{timeout} seconds." example.example.set_exception(e)
end end
raise inner_timeout if inner_timeout
rescue SystemExit => e rescue SystemExit => e
raise "Unexpected exit with status #{e.status}." example.example.set_exception(e)
ensure ensure
ENV.replace(@__env) ENV.replace(@__env)