Skip to content

Commit db017da

Browse files
committed
Simplify test
1 parent eb889d2 commit db017da

File tree

1 file changed

+9
-15
lines changed

1 file changed

+9
-15
lines changed

test/test_timeout.rb

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -172,23 +172,17 @@ def test_threadgroup
172172
end;
173173
end
174174

175+
# https://github.com/ruby/timeout/issues/24
175176
def test_handling_enclosed_threadgroup
176-
# The problem "add: can't move from the enclosed thread group" #24,
177-
# happens when the timeout_thread is created in an enclosed ThreadGroup.
178177
assert_separately(%w[-rtimeout], <<-'end;')
179-
t1 = Thread.new {
180-
Thread.stop
181-
assert_block do
182-
Timeout.timeout(0.1) {}
183-
true
184-
end
185-
}
186-
sleep 0.1 while t1.status != 'sleep'
187-
group = ThreadGroup.new
188-
group.add(t1)
189-
group.enclose
190-
t1.run
191-
t1.join
178+
Thread.new {
179+
t = Thread.current
180+
group = ThreadGroup.new
181+
group.add(t)
182+
group.enclose
183+
184+
assert_equal 42, Timeout.timeout(1) { 42 }
185+
}.join
192186
end;
193187
end
194188
end

0 commit comments

Comments
 (0)