diff options
author | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-07-22 16:48:49 +0000 |
---|---|---|
committer | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-07-22 16:48:49 +0000 |
commit | 4ed06c9cb79b70da0b5a742cb789f4c22cd46d18 (patch) | |
tree | 0431d6823f77dedd2cca5c6e487a2c5ef2797bf2 /test | |
parent | c7eb973984d71ae8dcb960e42134ee54a97c3a24 (diff) | |
download | ruby-4ed06c9cb79b70da0b5a742cb789f4c22cd46d18.tar.gz |
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
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_thread.rb | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/test/ruby/test_thread.rb b/test/ruby/test_thread.rb index 1f87304c3e..cdaec573d9 100644 --- a/test/ruby/test_thread.rb +++ b/test/ruby/test_thread.rb @@ -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 |