DEV: Add a per-spec timeout (#21648)
This commit is contained in:
parent
61f0b26035
commit
928d608ce7
|
@ -163,6 +163,8 @@ else
|
|||
TestProf::LetItBe.configure { |config| config.alias_to :fab!, refind: true }
|
||||
end
|
||||
|
||||
PER_SPEC_TIMEOUT_SECONDS = 30
|
||||
|
||||
RSpec.configure do |config|
|
||||
config.fail_fast = ENV["RSPEC_FAIL_FAST"] == "1"
|
||||
config.silence_filter_announcements = ENV["RSPEC_SILENCE_FILTER_ANNOUNCEMENTS"] == "1"
|
||||
|
@ -368,6 +370,16 @@ RSpec.configure do |config|
|
|||
"DiscourseEvent registrations were not cleaned up"
|
||||
end
|
||||
|
||||
if ENV["CI"]
|
||||
config.around do |example|
|
||||
Timeout.timeout(
|
||||
PER_SPEC_TIMEOUT_SECONDS,
|
||||
nil,
|
||||
"Spec timed out after #{PER_SPEC_TIMEOUT_SECONDS} seconds",
|
||||
) { example.run }
|
||||
end
|
||||
end
|
||||
|
||||
config.before :each do
|
||||
# This allows DB.transaction_open? to work in tests. See lib/mini_sql_multisite_connection.rb
|
||||
DB.test_transaction = ActiveRecord::Base.connection.current_transaction
|
||||
|
|
Loading…
Reference in New Issue