DEV: Add a per-spec timeout (#21648)

This commit is contained in:
Jarek Radosz 2023-05-19 12:08:48 +02:00 committed by GitHub
parent 61f0b26035
commit 928d608ce7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 0 deletions

View File

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