Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issues with specs again #2514

Merged
merged 2 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions sentry-ruby/spec/isolated/init.rb
Original file line number Diff line number Diff line change
@@ -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)
15 changes: 15 additions & 0 deletions sentry-ruby/spec/isolated/init_spec.rb
Original file line number Diff line number Diff line change
@@ -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
39 changes: 0 additions & 39 deletions sentry-ruby/spec/sentry_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions sentry-ruby/spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion sentry-sidekiq/spec/sentry/rails_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Loading