diff --git a/test/test_timeout.rb b/test/test_timeout.rb index 89fb10a..c3349d0 100644 --- a/test/test_timeout.rb +++ b/test/test_timeout.rb @@ -172,23 +172,17 @@ def test_threadgroup 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