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:
naruse 2012-07-22 16:48:49 +00:00
Родитель c7eb973984
Коммит 4ed06c9cb7
1 изменённых файлов: 20 добавлений и 18 удалений

Просмотреть файл

@ -681,6 +681,26 @@ class TestThread < Test::Unit::TestCase
assert_equal(:ok, q.pop)
}
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
class TestThreadGroup < Test::Unit::TestCase
@ -774,22 +794,4 @@ class TestThreadGroup < Test::Unit::TestCase
end
assert_in_delta(t1 - t0, 1, 1)
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