envutil.rb: check stdout and stderr

* test/ruby/envutil.rb (Test::Unit::Assertions#assert_in_out_err):
  check stdout and stderr both.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38703 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2013-01-05 03:25:44 +00:00
parent c6f7ecaebc
commit 3caea6b6a2
2 changed files with 19 additions and 10 deletions

View File

@ -1,3 +1,8 @@
Sat Jan 5 12:25:42 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
* test/ruby/envutil.rb (Test::Unit::Assertions#assert_in_out_err):
check stdout and stderr both.
Sat Jan 5 10:21:54 2013 Eric Hodel <drbrain@segment7.net> Sat Jan 5 10:21:54 2013 Eric Hodel <drbrain@segment7.net>
* doc/syntax/modules_and_classes.rdoc: Added documentation of syntax * doc/syntax/modules_and_classes.rdoc: Added documentation of syntax

View File

@ -187,18 +187,22 @@ module Test
if block_given? if block_given?
raise "test_stdout ignored, use block only or without block" if test_stdout != [] raise "test_stdout ignored, use block only or without block" if test_stdout != []
raise "test_stderr ignored, use block only or without block" if test_stderr != [] raise "test_stderr ignored, use block only or without block" if test_stderr != []
yield(stdout.lines.map {|l| l.chomp }, stderr.lines.map {|l| l.chomp }) yield(stdout.lines.map {|l| l.chomp }, stderr.lines.map {|l| l.chomp }, status)
else else
if test_stdout.is_a?(Regexp) errs = []
assert_match(test_stdout, stdout, message) [[test_stdout, stdout], [test_stderr, stderr]].each do |exp, act|
else begin
assert_equal(test_stdout, stdout.lines.map {|l| l.chomp }, message) if exp.is_a?(Regexp)
end assert_match(exp, act, message)
if test_stderr.is_a?(Regexp) else
assert_match(test_stderr, stderr, message) assert_equal(exp, act.lines.map {|l| l.chomp }, message)
else end
assert_equal(test_stderr, stderr.lines.map {|l| l.chomp }, message) rescue MiniTest::Assertion => e
errs << e.message
message = nil
end
end end
raise MiniTest::Assertion, errs.join("\n---\n") unless errs.empty?
status status
end end
end end