diff --git a/sentry-ruby/spec/isolated/init.rb b/sentry-ruby/spec/isolated/init.rb new file mode 100644 index 000000000..26e5c8682 --- /dev/null +++ b/sentry-ruby/spec/isolated/init.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +require_relative "../spec_helper" + +Sentry.init do |config| + config.dsn = Sentry::TestHelper::DUMMY_DSN +end + +trap('HUP') do + hub = Sentry.get_main_hub + puts hub.class +end + +Process.kill('HUP', Process.pid) diff --git a/sentry-ruby/spec/isolated/init_spec.rb b/sentry-ruby/spec/isolated/init_spec.rb new file mode 100644 index 000000000..3e731f195 --- /dev/null +++ b/sentry-ruby/spec/isolated/init_spec.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +require_relative "../spec_helper" + +SimpleCov.command_name "RSpecIsolated" + +RSpec.describe Sentry do + context "works within a trap context", when: { ruby_engine?: "ruby" } do + it "doesn't raise error when accessing main hub in trap context" do + out = `ruby spec/isolated/init.rb` + + expect(out).to include("Sentry::Hub") + end + end +end diff --git a/sentry-ruby/spec/sentry_spec.rb b/sentry-ruby/spec/sentry_spec.rb index 7fe45873c..9a188e9f3 100644 --- a/sentry-ruby/spec/sentry_spec.rb +++ b/sentry-ruby/spec/sentry_spec.rb @@ -70,45 +70,6 @@ end end end - - context "works within a trap context", when: { ruby_engine?: "ruby", ruby_version?: [:>=, "3.4"] } do - it "doesn't raise error when accessing main hub in trap context" do - read_pipe, write_pipe = IO.pipe - - pid = fork do - described_class.init do |config| - config.dsn = Sentry::TestHelper::DUMMY_DSN - end - - trap('HUP') do - hub = described_class.get_main_hub - - write_pipe.write(hub.class.to_s) - write_pipe.close - end - - Process.kill('HUP', Process.pid) - end - - write_pipe.close - - result = nil - retries = 0 - - while retries < 10 - break if Process.wait(pid) - - sleep 0.01 - - retries += 1 - end - - result = read_pipe.read - read_pipe.close - - expect(result).to eq("Sentry::Hub") - end - end end describe "#clone_hub_to_current_thread" do diff --git a/sentry-ruby/spec/spec_helper.rb b/sentry-ruby/spec/spec_helper.rb index d4c1a4033..00b3b310e 100644 --- a/sentry-ruby/spec/spec_helper.rb +++ b/sentry-ruby/spec/spec_helper.rb @@ -26,8 +26,8 @@ require "sentry-ruby" require "sentry/test_helper" -require "support/profiler" -require "support/stacktrace_test_fixture" +require_relative "support/profiler" +require_relative "support/stacktrace_test_fixture" RSpec.configure do |config| # Enable flags like --only-failures and --next-failure diff --git a/sentry-sidekiq/spec/sentry/rails_spec.rb b/sentry-sidekiq/spec/sentry/rails_spec.rb index a68133ebb..4026ed4d6 100644 --- a/sentry-sidekiq/spec/sentry/rails_spec.rb +++ b/sentry-sidekiq/spec/sentry/rails_spec.rb @@ -22,7 +22,7 @@ def self.name app.config.hosts = nil app.config.secret_key_base = "test" - app.config.eager_load = true + app.config.eager_load = false app.initializer :configure_sentry do Sentry.init do |config| config.release = 'beta'