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.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41421 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2013-06-19 07:47:26 +00:00
parent c704bb3149
commit 689333a0ba
3 changed files with 24 additions and 33 deletions

View File

@ -2,26 +2,15 @@ require 'test/unit'
class TestHideSkip < Test::Unit::TestCase class TestHideSkip < Test::Unit::TestCase
def test_hideskip def test_hideskip
test_out, o = IO.pipe assert_match(/assertions\/s.\n\n 1\) Skipped/, hideskip)
spawn(*@options[:ruby], "#{File.dirname(__FILE__)}/test4test_hideskip.rb", assert_match(/assertions\/s.\n\n 1\) Skipped/, hideskip("--show-skip"))
"--verbose", out: o, err: o) assert_match(/assertions\/s.\n\n1 tests, 0 assertions, 0 failures, 0 errors, 1 skips/, hideskip("--hide-skip"))
o.close end
assert_match(/assertions\/s.\n\n 1\) Skipped/,test_out.read)
test_out.close
test_out, o = IO.pipe def hideskip(*args)
spawn(*@options[:ruby], "#{File.dirname(__FILE__)}/test4test_hideskip.rb", IO.popen([*@options[:ruby], "#{File.dirname(__FILE__)}/test4test_hideskip.rb",
"--verbose", "--show-skip", out: o, err: o) "--verbose", *args], err: [:child, :out]) {|f|
o.close f.read
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", "--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
end end
end end

View File

@ -2,12 +2,14 @@ require 'test/unit'
class TestRedefinition < Test::Unit::TestCase class TestRedefinition < Test::Unit::TestCase
def test_redefinition 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$/, assert_match /^test\/unit warning: method TestForTestRedefinition#test_redefinition is redefined$/,
test_out.read redefinition
test_out.close end
def redefinition(*args)
IO.popen([*@options[:ruby], "#{File.dirname(__FILE__)}/test4test_redefinition.rb", *args],
err: [:child, :out]) {|f|
f.read
}
end end
end end

View File

@ -2,16 +2,16 @@ require 'test/unit'
class TestTestUnitSorting < Test::Unit::TestCase class TestTestUnitSorting < Test::Unit::TestCase
def test_sorting def test_sorting
test_out, o = IO.pipe result = sorting
spawn(*@options[:ruby], "#{File.dirname(__FILE__)}/test4test_sorting.rb",
"--verbose", out: o, err: o)
o.close
result = test_out.read
assert_match(/^ 1\) Skipped:/, result) assert_match(/^ 1\) Skipped:/, result)
assert_match(/^ 2\) Failure:/, result) assert_match(/^ 2\) Failure:/, result)
assert_match(/^ 3\) Error:/, 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
end end