DEV: Rescue the timeout error for a better spec cleanup (#21826)

Rescuing them still makes timing-out tests fail but doesn't break `after` spec cleanup (which could trigger more errors) Using custom error class to avoid any other possible timeout-catching code.

Also:
* remove an unnecessary `.select { |x| x.size > 0 }`
* fix a typo in a test title
This commit is contained in:
Jarek Radosz 2023-05-30 19:14:54 +02:00 committed by GitHub
parent 111ac4c7f2
commit 3569a48b2d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 6 deletions

View File

@ -178,9 +178,7 @@ module TurboTests
env["DISCOURSE_RSPEC_PROFILE_EACH_EXAMPLE"] = "1" if @profile
if @verbose
command_str =
[env.map { |k, v| "#{k}=#{v}" }.join(" "), command.join(" ")].select { |x| x.size > 0 }
.join(" ")
command_str = [env.map { |k, v| "#{k}=#{v}" }.join(" "), command.join(" ")].join(" ")
STDOUT.puts "::group::[#{process_id}] Run RSpec" if ENV["GITHUB_ACTIONS"]
STDOUT.puts "Process #{process_id}: #{command_str}"

View File

@ -64,7 +64,7 @@ RSpec.describe "Browse page", type: :system, js: true do
end
end
context "when filtering resuls" do
context "when filtering results" do
fab!(:category_channel_1) { Fabricate(:chat_channel, name: "foo") }
fab!(:category_channel_2) { Fabricate(:chat_channel, name: "bar") }

View File

@ -360,12 +360,18 @@ RSpec.configure do |config|
end
if ENV["CI"]
class SpecTimeoutError < StandardError
end
config.around do |example|
Timeout.timeout(
PER_SPEC_TIMEOUT_SECONDS,
nil,
SpecTimeoutError,
"Spec timed out after #{PER_SPEC_TIMEOUT_SECONDS} seconds",
) { example.run }
) do
example.run
rescue SpecTimeoutError
end
end
end