Skip to content

Commit

Permalink
Simplify test
Browse files Browse the repository at this point in the history
  • Loading branch information
eregon committed Feb 15, 2023
1 parent 3bcf3bb commit 850abeb
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions test/test_timeout.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 850abeb

Please sign in to comment.