Skip to content

A platform for community discussion. Free, open, simple.

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

Jarek Radosz3569a48b2dab
diff --git a/lib/turbo_tests/runner.rb b/lib/turbo_tests/runner.rb
index 946217088cb..c404a87f377 100644
--- a/lib/turbo_tests/runner.rb
+++ b/lib/turbo_tests/runner.rb
@@ -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}"
diff --git a/plugins/chat/spec/system/browse_page_spec.rb b/plugins/chat/spec/system/browse_page_spec.rb
index b462daa788e..89690cfaa27 100644
--- a/plugins/chat/spec/system/browse_page_spec.rb
+++ b/plugins/chat/spec/system/browse_page_spec.rb
@@ -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") }
diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb
index aefe966ad4e..79e13579a15 100644
--- a/spec/rails_helper.rb
+++ b/spec/rails_helper.rb
@@ -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