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

ruby-changes:26652

From: nobu <ko1@a...>
Date: Sat, 5 Jan 2013 12:25:55 +0900 (JST)
Subject: [ruby-changes:26652] nobu:r38703 (trunk): envutil.rb: check stdout and stderr

nobu	2013-01-05 12:25:44 +0900 (Sat, 05 Jan 2013)

  New Revision: 38703

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

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

  Modified files:
    trunk/ChangeLog
    trunk/test/ruby/envutil.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 38702)
+++ ChangeLog	(revision 38703)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sat Jan  5 12:25:42 2013  Nobuyoshi Nakada  <nobu@r...>
+
+	* 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@s...>
 
 	* doc/syntax/modules_and_classes.rdoc:  Added documentation of syntax
Index: test/ruby/envutil.rb
===================================================================
--- test/ruby/envutil.rb	(revision 38702)
+++ test/ruby/envutil.rb	(revision 38703)
@@ -187,18 +187,22 @@ module Test https://github.com/ruby/ruby/blob/trunk/test/ruby/envutil.rb#L187
         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

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

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