summaryrefslogtreecommitdiff
path: root/spec/ruby
diff options
context:
space:
mode:
authorJean Boussier <byroot@ruby-lang.org>2023-02-06 12:30:50 +0100
committerJean Boussier <jean.boussier@gmail.com>2023-02-06 19:35:38 +0100
commitfa49651e05a06512e18ccb2f54a7198c9ff579de (patch)
tree76f9cd0a4fc774ea236d33ec4d8b396b0b85da37 /spec/ruby
parent28da9909849dc02abe74de8170fe4036534361ba (diff)
Only emit circular dependency warning for owned thread shields
[Bug #19415] If multiple threads attemps to load the same file concurrently it's not a circular dependency issue. So we check that the existing ThreadShield is owner by the current fiber before warning about circular dependencies.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/7252
Diffstat (limited to 'spec/ruby')
-rw-r--r--spec/ruby/core/kernel/shared/require.rb10
-rw-r--r--spec/ruby/fixtures/code/concurrent_require_fixture.rb1
2 files changed, 11 insertions, 0 deletions
diff --git a/spec/ruby/core/kernel/shared/require.rb b/spec/ruby/core/kernel/shared/require.rb
index 666ca15e11..c629b44389 100644
--- a/spec/ruby/core/kernel/shared/require.rb
+++ b/spec/ruby/core/kernel/shared/require.rb
@@ -237,6 +237,16 @@ describe :kernel_require, shared: true do
}.should complain(/circular require considered harmful/, verbose: true)
ScratchPad.recorded.should == [:loaded]
end
+
+ ruby_bug "#17340", ''...'3.3' do
+ it "loads a file concurrently" do
+ path = File.expand_path "concurrent_require_fixture.rb", CODE_LOADING_DIR
+ ScratchPad.record(@object)
+ -> {
+ @object.require(path)
+ }.should_not complain(/circular require considered harmful/, verbose: true)
+ end
+ end
end
describe "(non-extensioned path)" do
diff --git a/spec/ruby/fixtures/code/concurrent_require_fixture.rb b/spec/ruby/fixtures/code/concurrent_require_fixture.rb
new file mode 100644
index 0000000000..fbb036214b
--- /dev/null
+++ b/spec/ruby/fixtures/code/concurrent_require_fixture.rb
@@ -0,0 +1 @@
+Thread.new { ScratchPad.recorded.require(__FILE__) }.join(0.1)