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>
* doc/syntax/modules_and_classes.rdoc: Added documentation of syntax

View File

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