[前][次][番号順一覧][スレッド一覧]

ruby-changes:29363

From: nobu <ko1@a...>
Date: Wed, 19 Jun 2013 16:47:25 +0900 (JST)
Subject: [ruby-changes:29363] nobu:r41415 (trunk): test/ruby: reap zombies

nobu	2013-06-19 16:47:12 +0900 (Wed, 19 Jun 2013)

  New Revision: 41415

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=41415

  Log:
    test/ruby: reap zombies

  Modified files:
    trunk/test/ruby/test_fiber.rb
    trunk/test/ruby/test_io.rb
    trunk/test/ruby/test_require.rb
    trunk/test/ruby/test_rubyoptions.rb
    trunk/test/ruby/test_signal.rb

Index: test/ruby/test_fiber.rb
===================================================================
--- test/ruby/test_fiber.rb	(revision 41414)
+++ test/ruby/test_fiber.rb	(revision 41415)
@@ -248,12 +248,13 @@ class TestFiber < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_fiber.rb#L248
 
   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
Index: test/ruby/test_require.rb
===================================================================
--- test/ruby/test_require.rb	(revision 41414)
+++ test/ruby/test_require.rb	(revision 41415)
@@ -382,7 +382,7 @@ class TestRequire < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_require.rb#L382
         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"
Index: test/ruby/test_signal.rb
===================================================================
--- test/ruby/test_signal.rb	(revision 41414)
+++ test/ruby/test_signal.rb	(revision 41415)
@@ -6,7 +6,7 @@ require_relative 'envutil' https://github.com/ruby/ruby/blob/trunk/test/ruby/test_signal.rb#L6
 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 https://github.com/ruby/ruby/blob/trunk/test/ruby/test_signal.rb#L52
   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 https://github.com/ruby/ruby/blob/trunk/test/ruby/test_signal.rb#L67
       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 https://github.com/ruby/ruby/blob/trunk/test/ruby/test_signal.rb#L199
     end
     w.close
     assert_equal(r.read, "foo")
+  ensure
+    Process.wait(pid) if pid
   end
 
   def test_signal_requiring
Index: test/ruby/test_io.rb
===================================================================
--- test/ruby/test_io.rb	(revision 41414)
+++ test/ruby/test_io.rb	(revision 41415)
@@ -922,9 +922,14 @@ class TestIO < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_io.rb#L922
     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
Index: test/ruby/test_rubyoptions.rb
===================================================================
--- test/ruby/test_rubyoptions.rb	(revision 41414)
+++ test/ruby/test_rubyoptions.rb	(revision 41415)
@@ -472,6 +472,7 @@ class TestRubyOptions < Test::Unit::Test https://github.com/ruby/ruby/blob/trunk/test/ruby/test_rubyoptions.rb#L472
       end
       assert_match(/hello world/, ps)
       Process.kill :KILL, pid
+      Process.wait(pid)
     end
   end
 

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]