diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-06-19 07:47:12 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-06-19 07:47:12 +0000 |
commit | 4835230fef0005666e89fd1e2da5ad03ddb78315 (patch) | |
tree | ea99eaee3a04a5710f8a10900f76d637fb0069f1 /test | |
parent | c4561c29348c357f50162cdd5c16d8b98d8cd0fa (diff) |
test/ruby: reap zombies
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41415 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_fiber.rb | 5 | ||||
-rw-r--r-- | test/ruby/test_io.rb | 5 | ||||
-rw-r--r-- | test/ruby/test_require.rb | 2 | ||||
-rw-r--r-- | test/ruby/test_rubyoptions.rb | 1 | ||||
-rw-r--r-- | test/ruby/test_signal.rb | 12 |
5 files changed, 19 insertions, 6 deletions
diff --git a/test/ruby/test_fiber.rb b/test/ruby/test_fiber.rb index 38050386c4..957c134589 100644 --- a/test/ruby/test_fiber.rb +++ b/test/ruby/test_fiber.rb @@ -248,12 +248,13 @@ class TestFiber < Test::Unit::TestCase def test_fork_from_fiber begin - Process.fork{} + pid = Process.fork{} rescue NotImplementedError return + else + Process.wait(pid) end bug5700 = '[ruby-core:41456]' - pid = nil assert_nothing_raised(bug5700) do Fiber.new{ pid = fork {} }.resume end diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb index e42ace1952..6c62695d6c 100644 --- a/test/ruby/test_io.rb +++ b/test/ruby/test_io.rb @@ -922,9 +922,14 @@ class TestIO < Test::Unit::TestCase args = ['-e', '$>.write($<.read)'] if args.empty? ruby = EnvUtil.rubybin f = IO.popen([ruby] + args, 'r+') + pid = f.pid yield(f) ensure f.close unless !f || f.closed? + begin + Process.wait(pid) + rescue Errno::ECHILD, Errno::ESRCH + end end def test_try_convert diff --git a/test/ruby/test_require.rb b/test/ruby/test_require.rb index 663c125708..77b2a6fbf4 100644 --- a/test/ruby/test_require.rb +++ b/test/ruby/test_require.rb @@ -382,7 +382,7 @@ class TestRequire < Test::Unit::TestCase File.open("a/tst.rb", "w") {|f| f.puts 'require_relative "lib"' } begin File.symlink("../a/tst.rb", "b/tst.rb") - result = IO.popen([EnvUtil.rubybin, "b/tst.rb"]).read + result = IO.popen([EnvUtil.rubybin, "b/tst.rb"], &:read) assert_equal("a/lib.rb\n", result, "[ruby-dev:40040]") rescue NotImplementedError skip "File.symlink is not implemented" diff --git a/test/ruby/test_rubyoptions.rb b/test/ruby/test_rubyoptions.rb index e43224fbcb..c06d554cd9 100644 --- a/test/ruby/test_rubyoptions.rb +++ b/test/ruby/test_rubyoptions.rb @@ -472,6 +472,7 @@ class TestRubyOptions < Test::Unit::TestCase end assert_match(/hello world/, ps) Process.kill :KILL, pid + Process.wait(pid) end end diff --git a/test/ruby/test_signal.rb b/test/ruby/test_signal.rb index 166ecc085c..fb07bffa9d 100644 --- a/test/ruby/test_signal.rb +++ b/test/ruby/test_signal.rb @@ -6,7 +6,7 @@ require_relative 'envutil' class TestSignal < Test::Unit::TestCase def have_fork? begin - Process.fork {} + Process.wait(Process.fork {}) return true rescue NotImplementedError return false @@ -52,7 +52,6 @@ class TestSignal < Test::Unit::TestCase end def test_exit_action - return unless have_fork? # skip this test begin r, w = IO.pipe r0, w0 = IO.pipe @@ -68,12 +67,17 @@ class TestSignal < Test::Unit::TestCase sleep 0.1 assert_nothing_raised("[ruby-dev:26128]") { Process.kill(:USR1, pid) + term = :TERM begin Timeout.timeout(3) { Process.waitpid pid } rescue Timeout::Error - Process.kill(:TERM, pid) + if term + Process.kill(term, pid) + term = (:KILL if term != :KILL) + retry + end raise end } @@ -195,6 +199,8 @@ class TestSignal < Test::Unit::TestCase end w.close assert_equal(r.read, "foo") + ensure + Process.wait(pid) if pid end def test_signal_requiring |