Use assert_normal_exit to avoid stack on buggy implementations.
fix for r36492. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36495 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
c7eb973984
commit
4ed06c9cb7
@ -681,6 +681,26 @@ class TestThread < Test::Unit::TestCase
|
|||||||
assert_equal(:ok, q.pop)
|
assert_equal(:ok, q.pop)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_thread_timer_and_ensure
|
||||||
|
assert_normal_exit(<<_eom, 'r36492', timeout: 3)
|
||||||
|
flag = false
|
||||||
|
t = Thread.new do
|
||||||
|
begin
|
||||||
|
sleep
|
||||||
|
ensure
|
||||||
|
1 until flag
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
Thread.pass until t.status == "sleep"
|
||||||
|
|
||||||
|
t.kill
|
||||||
|
t.alive? == true
|
||||||
|
flag = true
|
||||||
|
t.join
|
||||||
|
_eom
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class TestThreadGroup < Test::Unit::TestCase
|
class TestThreadGroup < Test::Unit::TestCase
|
||||||
@ -774,22 +794,4 @@ class TestThreadGroup < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
assert_in_delta(t1 - t0, 1, 1)
|
assert_in_delta(t1 - t0, 1, 1)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_thread_timer_and_ensure
|
|
||||||
exit = false
|
|
||||||
t = Thread.new do
|
|
||||||
begin
|
|
||||||
sleep
|
|
||||||
ensure
|
|
||||||
1 until exit # Ruby 1.8 won't switch threads here
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
Thread.pass until t.status == "sleep"
|
|
||||||
|
|
||||||
t.kill
|
|
||||||
t.alive? == true
|
|
||||||
exit = true
|
|
||||||
t.join
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user