diff options
author | Luke Gruber <[email protected]> | 2025-05-23 11:12:14 -0400 |
---|---|---|
committer | Jean Boussier <[email protected]> | 2025-05-23 21:13:23 +0200 |
commit | f64c89f18d3a0cd15ea334d43f73f72e7bd99140 (patch) | |
tree | 5cf4aabd85183cd3c7a3217ed2d1dedc2364a02a /test/ruby | |
parent | b7e751181eefbce272958d62c26e396ac16363c1 (diff) |
Fix 'require' from a ractor when the required file raises an error
If you catch an error that was raised from a file you required in
a ractor, that error did not have its belonging reset from the main
ractor to the current ractor, so you hit assertion errors in debug
mode.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/13428
Diffstat (limited to 'test/ruby')
-rw-r--r-- | test/ruby/test_ractor.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/ruby/test_ractor.rb b/test/ruby/test_ractor.rb index e61c6beffc..abfbc18218 100644 --- a/test/ruby/test_ractor.rb +++ b/test/ruby/test_ractor.rb @@ -79,6 +79,25 @@ class TestRactor < Test::Unit::TestCase end; end + def test_require_raises_and_no_ractor_belonging_issue + assert_ractor(<<~'RUBY') + require "tempfile" + f = Tempfile.new(["file_to_require_from_ractor", ".rb"]) + f.write("raise 'uh oh'") + f.flush + err_msg = Ractor.new(f.path) do |path| + begin + require path + rescue RuntimeError => e + e.message # had confirm belonging issue here + else + nil + end + end.take + assert_equal "uh oh", err_msg + RUBY + end + def assert_make_shareable(obj) refute Ractor.shareable?(obj), "object was already shareable" Ractor.make_shareable(obj) |