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

ruby-changes:29368

From: nobu <ko1@a...>
Date: Wed, 19 Jun 2013 16:47:59 +0900 (JST)
Subject: [ruby-changes:29368] nobu:r41421 (trunk): test/testunit: reap zombie

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

  New Revision: 41421

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

  Log:
    test/testunit: reap zombie
    
    * test/testunit/test_hideskip.rb (test_hideskip): reap zombie by
      reading with IO.popen instead of separated spawn and assert.
    
    * test/testunit/test_redefinition.rb (test_redefinition): ditto.
    
    * test/testunit/test_sorting.rb (test_sorting): ditto.

  Modified files:
    trunk/test/testunit/test_hideskip.rb
    trunk/test/testunit/test_redefinition.rb
    trunk/test/testunit/test_sorting.rb

Index: test/testunit/test_redefinition.rb
===================================================================
--- test/testunit/test_redefinition.rb	(revision 41420)
+++ test/testunit/test_redefinition.rb	(revision 41421)
@@ -2,12 +2,14 @@ require 'test/unit' https://github.com/ruby/ruby/blob/trunk/test/testunit/test_redefinition.rb#L2
 
 class TestRedefinition < Test::Unit::TestCase
   def test_redefinition
-    test_out, o = IO.pipe
-    spawn(*@options[:ruby], "#{File.dirname(__FILE__)}/test4test_redefinition.rb", out: File::NULL, err: o)
-    o.close
-
     assert_match /^test\/unit warning: method TestForTestRedefinition#test_redefinition is redefined$/,
-                 test_out.read
-    test_out.close
+                 redefinition
+  end
+
+  def redefinition(*args)
+    IO.popen([*@options[:ruby], "#{File.dirname(__FILE__)}/test4test_redefinition.rb", *args],
+                      err: [:child, :out]) {|f|
+      f.read
+    }
   end
 end
Index: test/testunit/test_hideskip.rb
===================================================================
--- test/testunit/test_hideskip.rb	(revision 41420)
+++ test/testunit/test_hideskip.rb	(revision 41421)
@@ -2,26 +2,15 @@ require 'test/unit' https://github.com/ruby/ruby/blob/trunk/test/testunit/test_hideskip.rb#L2
 
 class TestHideSkip < Test::Unit::TestCase
   def test_hideskip
-    test_out, o = IO.pipe
-    spawn(*@options[:ruby], "#{File.dirname(__FILE__)}/test4test_hideskip.rb",
-          "--verbose", out: o, err: o)
-    o.close
-    assert_match(/assertions\/s.\n\n  1\) Skipped/,test_out.read)
-    test_out.close
-
-    test_out, o = IO.pipe
-    spawn(*@options[:ruby], "#{File.dirname(__FILE__)}/test4test_hideskip.rb",
-          "--verbose", "--show-skip", out: o, err: o)
-    o.close
-    assert_match(/assertions\/s.\n\n  1\) Skipped/,test_out.read)
-    test_out.close
+    assert_match(/assertions\/s.\n\n  1\) Skipped/, hideskip)
+    assert_match(/assertions\/s.\n\n  1\) Skipped/, hideskip("--show-skip"))
+    assert_match(/assertions\/s.\n\n1 tests, 0 assertions, 0 failures, 0 errors, 1 skips/, hideskip("--hide-skip"))
+  end
 
-    test_out, o = IO.pipe
-    spawn(*@options[:ruby], "#{File.dirname(__FILE__)}/test4test_hideskip.rb",
-          "--verbose", "--hide-skip", out: o, err: o)
-    o.close
-    assert_match(/assertions\/s.\n\n1 tests, 0 assertions, 0 failures, 0 errors, 1 skips/,
-                 test_out.read)
-    test_out.close
+  def hideskip(*args)
+    IO.popen([*@options[:ruby], "#{File.dirname(__FILE__)}/test4test_hideskip.rb",
+                       "--verbose", *args], err: [:child, :out]) {|f|
+      f.read
+    }
   end
 end
Index: test/testunit/test_sorting.rb
===================================================================
--- test/testunit/test_sorting.rb	(revision 41420)
+++ test/testunit/test_sorting.rb	(revision 41421)
@@ -2,16 +2,16 @@ require 'test/unit' https://github.com/ruby/ruby/blob/trunk/test/testunit/test_sorting.rb#L2
 
 class TestTestUnitSorting < Test::Unit::TestCase
   def test_sorting
-    test_out, o = IO.pipe
-    spawn(*@options[:ruby], "#{File.dirname(__FILE__)}/test4test_sorting.rb",
-          "--verbose", out: o, err: o)
-    o.close
-    result = test_out.read
-
+    result = sorting
     assert_match(/^  1\) Skipped:/, result)
     assert_match(/^  2\) Failure:/, result)
     assert_match(/^  3\) Error:/,   result)
+  end
 
-    test_out.close
+  def sorting(*args)
+    IO.popen([*@options[:ruby], "#{File.dirname(__FILE__)}/test4test_sorting.rb",
+              "--verbose", *args], err: [:child, :out]) {|f|
+      f.read
+    }
   end
 end

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

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