diff --git a/test/ruby/test_backtrace.rb b/test/ruby/test_backtrace.rb index c4545239a5..0c7677a781 100644 --- a/test/ruby/test_backtrace.rb +++ b/test/ruby/test_backtrace.rb @@ -212,6 +212,7 @@ class TestBacktrace < Test::Unit::TestCase assert_equal(bt, locs) ensure q << true + th.join end end diff --git a/test/ruby/test_beginendblock.rb b/test/ruby/test_beginendblock.rb index d9c1f56916..a4318493c1 100644 --- a/test/ruby/test_beginendblock.rb +++ b/test/ruby/test_beginendblock.rb @@ -127,6 +127,7 @@ EOW def test_endblock_raise ruby = EnvUtil.rubybin + th = nil out = IO.popen( [ruby, '-e', 'class C; def write(x); puts x; STDOUT.flush; sleep 0.01; end; end', @@ -134,11 +135,13 @@ EOW '-e', 'END {raise "e1"}; END {puts "e2"}', '-e', 'END {raise "e3"}; END {puts "e4"}', '-e', 'END {raise "e5"}; END {puts "e6"}']) {|f| - Thread.new {sleep 5; Process.kill :KILL, f.pid} + th = Thread.new {sleep 5; Process.kill :KILL, f.pid} f.read } assert_match(/e1/, out) assert_match(/e6/, out) + ensure + th.kill if th.alive? end def test_nested_at_exit diff --git a/test/ruby/test_proc.rb b/test/ruby/test_proc.rb index 1c8a053cca..284b518121 100644 --- a/test/ruby/test_proc.rb +++ b/test/ruby/test_proc.rb @@ -407,6 +407,7 @@ class TestProc < Test::Unit::TestCase t = Thread.new { sleep } assert_raise(ThreadError) { t.instance_eval { initialize { } } } t.kill + t.join end def test_to_proc diff --git a/test/ruby/test_threadgroup.rb b/test/ruby/test_threadgroup.rb index e29c477247..f4c03de67e 100644 --- a/test/ruby/test_threadgroup.rb +++ b/test/ruby/test_threadgroup.rb @@ -5,10 +5,13 @@ require_relative 'envutil' class TestThreadGroup < Test::Unit::TestCase def test_thread_init thgrp = ThreadGroup.new - Thread.new{ + th = Thread.new{ thgrp.add(Thread.current) - assert_equal(thgrp, Thread.new{sleep 1}.group) - }.join + Thread.new{sleep 1} + }.value + assert_equal(thgrp, th.group) + ensure + th.join end def test_frozen_thgroup