rubygem-rspec-support/rubygem-rspec-support-3.12.0-ReentrantMutex-insider-Fiber.patch

44 lines
1.6 KiB
Diff

From 5de969f09c60fb46b75c0df0a227d8b0a60d3b95 Mon Sep 17 00:00:00 2001
From: ojab <ojab@ojab.ru>
Date: Fri, 18 Nov 2022 15:12:19 +0000
Subject: [PATCH] Fix `ReentrantMutex` locking inside `Fiber` spec for ruby-3.2
It raises `ThreadError` since https://github.com/ruby/ruby/pull/6680
---
spec/rspec/support/reentrant_mutex_spec.rb | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/spec/rspec/support/reentrant_mutex_spec.rb b/spec/rspec/support/reentrant_mutex_spec.rb
index 9bef54ee..34c2b27c 100644
--- a/spec/rspec/support/reentrant_mutex_spec.rb
+++ b/spec/rspec/support/reentrant_mutex_spec.rb
@@ -28,7 +28,18 @@
order.join_all
end
- if RUBY_VERSION >= '3.0'
+ if RUBY_VERSION >= '3.1.3'
+ 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
@@ -36,7 +47,7 @@
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