[ruby/timeout] Simplify test

https://github.com/ruby/timeout/commit/db017da726
This commit is contained in:
Benoit Daloze 2023-02-15 19:26:13 +01:00 committed by git
parent 610375edfc
commit 70d84a5f3d

View File

@ -172,23 +172,17 @@ class TestTimeout < Test::Unit::TestCase
end;
end
# https://github.com/ruby/timeout/issues/24
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
Thread.new {
t = Thread.current
group = ThreadGroup.new
group.add(t)
group.enclose
assert_equal 42, Timeout.timeout(1) { 42 }
}.join
end;
end
end