mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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
1 changed files with 20 additions and 18 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue