From 9d7b0bad11d387e041e9fae7a4ba2e65f843900f Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Thu, 29 Oct 2020 09:50:17 +0000 Subject: [PATCH] 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 --- Library/Homebrew/test/spec_helper.rb | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/Library/Homebrew/test/spec_helper.rb b/Library/Homebrew/test/spec_helper.rb index dabc1816de..78d0dee36d 100644 --- a/Library/Homebrew/test/spec_helper.rb +++ b/Library/Homebrew/test/spec_helper.rb @@ -189,20 +189,15 @@ RSpec.configure do |config| end begin - timeout = example.metadata.fetch(:timeout, 120) - inner_timeout = nil + timeout = example.metadata.fetch(:timeout, 60) Timeout.timeout(timeout) do example.run - rescue Timeout::Error => e - inner_timeout = e end - rescue Timeout::Error - raise "Example exceeded maximum runtime of #{timeout} seconds." + rescue Timeout::Error => e + example.example.set_exception(e) end - - raise inner_timeout if inner_timeout rescue SystemExit => e - raise "Unexpected exit with status #{e.status}." + example.example.set_exception(e) ensure ENV.replace(@__env)