ruby-changes:34174
From: akr <ko1@a...>
Date: Fri, 30 May 2014 22:28:48 +0900 (JST)
Subject: [ruby-changes:34174] akr:r46255 (trunk): Join threads, not kill.
akr 2014-05-30 22:28:39 +0900 (Fri, 30 May 2014) New Revision: 46255 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?revision=46255&view=revision Log: Join threads, not kill. Modified files: trunk/test/io/console/test_io_console.rb Index: test/io/console/test_io_console.rb =================================================================== --- test/io/console/test_io_console.rb (revision 46254) +++ test/io/console/test_io_console.rb (revision 46255) @@ -26,9 +26,8 @@ class TestIO_Console < Test::Unit::TestC https://github.com/ruby/ruby/blob/trunk/test/io/console/test_io_console.rb#L26 end def test_raw_minchar - len = 0 - th = nil helper {|m, s| + len = 0 assert_equal([nil, 0], [s.getch(min: 0), len]) main = Thread.current go = false @@ -41,18 +40,19 @@ class TestIO_Console < Test::Unit::TestC https://github.com/ruby/ruby/blob/trunk/test/io/console/test_io_console.rb#L40 m.print("1234567890") m.flush } - assert_equal(["a", 1], [s.getch(min: 1), len]) - go = true - assert_equal(["1", 11], [s.getch, len]) + begin + assert_equal(["a", 1], [s.getch(min: 1), len]) + go = true + assert_equal(["1", 11], [s.getch, len]) + ensure + th.join + end } - ensure - th.kill if th and th.alive? end def test_raw_timeout - len = 0 - th = nil helper {|m, s| + len = 0 assert_equal([nil, 0], [s.getch(min: 0, time: 0.1), len]) main = Thread.current th = Thread.start { @@ -60,11 +60,13 @@ class TestIO_Console < Test::Unit::TestC https://github.com/ruby/ruby/blob/trunk/test/io/console/test_io_console.rb#L60 len += 2 m.print("ab") } - assert_equal(["a", 2], [s.getch(min: 1, time: 1), len]) - assert_equal(["b", 2], [s.getch(time: 1), len]) + begin + assert_equal(["a", 2], [s.getch(min: 1, time: 1), len]) + assert_equal(["b", 2], [s.getch(time: 1), len]) + ensure + th.join + end } - ensure - th.kill if th and th.alive? end def test_cooked -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/