summaryrefslogtreecommitdiff
path: root/test/test_timeout.rb
diff options
context:
space:
mode:
authorRick Blommers <rick@blommersit.nl>2023-02-12 15:23:37 +0100
committergit <svn-admin@ruby-lang.org>2023-02-15 19:25:05 +0000
commit610375edfc2ed487dc5798278a5923154aec1c1f (patch)
tree64813ed48d90e6d56cf6e333eeb83a115800b9be /test/test_timeout.rb
parent8943b0d411519adeebd0d3dbf7cef337eed1ed02 (diff)
downloadruby-610375edfc2ed487dc5798278a5923154aec1c1f.tar.gz
[ruby/timeout] Don't move the timer_thread when it's enclosed
Don't move the timer_thread to ThreadGroup::Default, when it's created in an enclosed ThreadGroup. Prevents the exception: "add" can't move from the enclosed thread group" https://github.com/ruby/timeout/commit/eb889d2c8b
Diffstat (limited to 'test/test_timeout.rb')
-rw-r--r--test/test_timeout.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/test_timeout.rb b/test/test_timeout.rb
index 2d3dd16245..89fb10a52c 100644
--- a/test/test_timeout.rb
+++ b/test/test_timeout.rb
@@ -172,4 +172,23 @@ class TestTimeout < Test::Unit::TestCase
end;
end
+ def test_handling_enclosed_threadgroup
+ # The problem "add: can't move from the enclosed thread group" #24,
+ # happens when the timeout_thread is created in an enclosed ThreadGroup.
+ assert_separately(%w[-rtimeout], <<-'end;')
+ t1 = Thread.new {
+ Thread.stop
+ assert_block do
+ Timeout.timeout(0.1) {}
+ true
+ end
+ }
+ sleep 0.1 while t1.status != 'sleep'
+ group = ThreadGroup.new
+ group.add(t1)
+ group.enclose
+ t1.run
+ t1.join
+ end;
+ end
end