A platform for community discussion. Free, open, simple.
DEV: Dump all threads for some flaky system tests (#32050)
Alan Guo Xiang Tan9d786ad870aa
diff --git a/spec/rails_helper.rb b/spec/rails_helper.rbindex 6a1602407f9..cc4e1b0228c 100644--- a/spec/rails_helper.rb+++ b/spec/rails_helper.rb@@ -406,17 +406,12 @@ RSpec.configure do |config|# Store timeout for later, we'll only raise it if the test otherwise passesRSpec.current_example.metadata[:_capybara_timeout_exception] ||= timeout_error- RSpec.current_example.metadata[:_capybara_server_threads_backtraces] = Thread- .list- .reduce([]) do |array, thread|- if thread.backtrace.any? { |line| line.include?("puma") }- app_backtraces = thread.backtrace.filter { |line| !line.match?(%r{/gems/}) }- array << app_backtraces if app_backtraces.any?- end-- array- end- .uniq+ if RSpec.current_example.metadata[:dump_threads_on_failure]+ RSpec.current_example.metadata[:_capybara_server_threads_backtraces] = Thread+ .list+ .reduce([]) { |array, thread| array << thread.backtrace }+ .uniq+ endraise # re-raise original errorelsediff --git a/spec/system/email_change_spec.rb b/spec/system/email_change_spec.rbindex 3d473eb8b23..fd88f4d9808 100644--- a/spec/system/email_change_spec.rb+++ b/spec/system/email_change_spec.rb@@ -51,7 +51,7 @@ describe "Changing email", type: :system dotry_until_success { expect(user.reload.primary_email.email).to eq(new_email) }end- it "works when user has totp 2fa" do+ it "works when user has totp 2fa", dump_threads_on_failure: true doSiteSetting.hide_email_address_taken = falsesecond_factor = Fabricate(:user_second_factor_totp, user: user)diff --git a/spec/system/forgot_password_spec.rb b/spec/system/forgot_password_spec.rbindex 7a73d8fc038..f122edcd9d6 100644--- a/spec/system/forgot_password_spec.rb+++ b/spec/system/forgot_password_spec.rb@@ -208,7 +208,7 @@ shared_examples "forgot password scenarios" doendend-describe "User resetting password", type: :system do+describe "User resetting password", type: :system, dump_threads_on_failure: true dodescribe "when desktop" doinclude_examples "forgot password scenarios"end