From 4ed06c9cb79b70da0b5a742cb789f4c22cd46d18 Mon Sep 17 00:00:00 2001 From: naruse Date: Sun, 22 Jul 2012 16:48:49 +0000 Subject: [PATCH] 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 --- test/ruby/test_thread.rb | 38 ++++++++++++++++++++------------------ 1 file 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