Skip to content
This repository has been archived by the owner on Nov 30, 2024. It is now read-only.

Fix ReentrantMutex locking inside Fiber spec for ruby-3.2 #553

Closed
wants to merge 1 commit into from
Closed
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
15 changes: 13 additions & 2 deletions spec/rspec/support/reentrant_mutex_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,26 @@
order.join_all
end

if RUBY_VERSION >= '3.0'
if RUBY_VERSION >= '3.2'
it 'raises an error when trying to lock from another Fiber' do
mutex.synchronize do
Fiber.new do
expect {
mutex.send(:enter)
raise 'should not reach here: mutex is already locked on different Fiber'
}.to raise_error(ThreadError, 'deadlock; lock already owned by another fiber belonging to the same thread')
end.resume
end
end
elsif RUBY_VERSION >= '3.0'
it 'waits when trying to lock from another Fiber' do
mutex.synchronize do
ready = false
f = Fiber.new do
expect {
ready = true
mutex.send(:enter)
raise 'should reach here: mutex is already locked on different Fiber'
raise 'should not reach here: mutex is already locked on different Fiber'
}.to raise_error(Exception, 'waited correctly')
end

Expand Down