ruby-changes:24444
From: naruse <ko1@a...>
Date: Mon, 23 Jul 2012 01:48:59 +0900 (JST)
Subject: [ruby-changes:24444] naruse:r36495 (trunk): Use assert_normal_exit to avoid stack on buggy implementations.
naruse 2012-07-23 01:48:49 +0900 (Mon, 23 Jul 2012) New Revision: 36495 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=36495 Log: Use assert_normal_exit to avoid stack on buggy implementations. fix for r36492. Modified files: trunk/test/ruby/test_thread.rb Index: test/ruby/test_thread.rb =================================================================== --- test/ruby/test_thread.rb (revision 36494) +++ test/ruby/test_thread.rb (revision 36495) @@ -681,6 +681,26 @@ 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 @@ 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 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/