summaryrefslogtreecommitdiff
path: root/test/test_timeout.rb
diff options
context:
space:
mode:
authorLars Kanis <lars@greiz-reinsdorf.de>2022-09-25 11:14:11 +0200
committergit <svn-admin@ruby-lang.org>2022-09-28 01:59:35 +0900
commit9d56d9975d867c94ab2a6d76e4482112ab6c3319 (patch)
treeecf30a93083f46d0f4efae0db32b6429314ac29f /test/test_timeout.rb
parent1a06bc94d96ab4be4386b0ccd802d11380fa4e84 (diff)
downloadruby-9d56d9975d867c94ab2a6d76e4482112ab6c3319.tar.gz
[ruby/timeout] Explicit add the timeout thread to default ThreadGroup
Otherwise the timeout thread would be added to the ThreadGroup of the thread that makes the first call to Timeout.timeout . Fixes bug 19020: https://bugs.ruby-lang.org/issues/19020 Add a test case to make sure the common thread doesn't leak to another ThreadGroup https://github.com/ruby/timeout/commit/c4f1385c9a
Diffstat (limited to 'test/test_timeout.rb')
-rw-r--r--test/test_timeout.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/test/test_timeout.rb b/test/test_timeout.rb
index 76de38949d..2d3dd16245 100644
--- a/test/test_timeout.rb
+++ b/test/test_timeout.rb
@@ -159,4 +159,17 @@ class TestTimeout < Test::Unit::TestCase
assert_equal 'timeout', r.read
r.close
end
+
+ def test_threadgroup
+ assert_separately(%w[-rtimeout], <<-'end;')
+ tg = ThreadGroup.new
+ thr = Thread.new do
+ tg.add(Thread.current)
+ Timeout.timeout(10){}
+ end
+ thr.join
+ assert_equal [].to_s, tg.list.to_s
+ end;
+ end
+
end