mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
spec_helper: fix Timeout::Error/SystemExit handling.
These need to be manually caught and set otherwise they will not be retried by `rspec-retry`. This is particularly annoying and a cause of CI failures when tests timeout but are not retried. Fixes https://github.com/Homebrew/brew/issues/8979
This commit is contained in:
parent
447fbc1cfc
commit
9d7b0bad11
@ -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)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user