ruby-changes:16910
From: akr <ko1@a...>
Date: Sat, 7 Aug 2010 19:58:20 +0900 (JST)
Subject: [ruby-changes:16910] Ruby:r28906 (trunk): * test/ruby/envutil.rb (EnvUtil.invoke_ruby): merge stdout and stderr
akr 2010-08-07 19:53:13 +0900 (Sat, 07 Aug 2010) New Revision: 28906 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=28906 Log: * test/ruby/envutil.rb (EnvUtil.invoke_ruby): merge stdout and stderr if capture_stderr is :merge_to_stdout. (assert_normal_exit): print abnormal output propery. Modified files: trunk/ChangeLog trunk/test/ruby/envutil.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 28905) +++ ChangeLog (revision 28906) @@ -1,3 +1,9 @@ +Sat Aug 7 19:51:10 2010 Tanaka Akira <akr@f...> + + * test/ruby/envutil.rb (EnvUtil.invoke_ruby): merge stdout and stderr + if capture_stderr is :merge_to_stdout. + (assert_normal_exit): print abnormal output propery. + Sat Aug 7 19:04:49 2010 Tanaka Akira <akr@f...> * missing/close.c: undef the macros "getpeername", "getsockname" and Index: test/ruby/envutil.rb =================================================================== --- test/ruby/envutil.rb (revision 28905) +++ test/ruby/envutil.rb (revision 28906) @@ -33,11 +33,11 @@ def invoke_ruby(args, stdin_data="", capture_stdout=false, capture_stderr=false, opt={}) in_c, in_p = IO.pipe out_p, out_c = IO.pipe if capture_stdout - err_p, err_c = IO.pipe if capture_stderr + err_p, err_c = IO.pipe if capture_stderr && capture_stderr != :merge_to_stdout opt = opt.dup opt[:in] = in_c opt[:out] = out_c if capture_stdout - opt[:err] = err_c if capture_stderr + opt[:err] = capture_stderr == :merge_to_stdout ? out_c : err_c if capture_stderr if enc = opt.delete(:encoding) out_p.set_encoding(enc) if out_p err_p.set_encoding(enc) if err_p @@ -52,23 +52,23 @@ pid = spawn(child_env, EnvUtil.rubybin, *args, opt) in_c.close out_c.close if capture_stdout - err_c.close if capture_stderr + err_c.close if capture_stderr && capture_stderr != :merge_to_stdout if block_given? return yield in_p, out_p, err_p else th_stdout = Thread.new { out_p.read } if capture_stdout - th_stderr = Thread.new { err_p.read } if capture_stderr + th_stderr = Thread.new { err_p.read } if capture_stderr && capture_stderr != :merge_to_stdout in_p.write stdin_data.to_str in_p.close timeout = opt.fetch(:timeout, 10) - if (!capture_stdout || th_stdout.join(timeout)) && (!capture_stderr || th_stderr.join(timeout)) + if (!th_stdout || th_stdout.join(timeout)) && (!th_stderr || th_stderr.join(timeout)) stdout = th_stdout.value if capture_stdout - stderr = th_stderr.value if capture_stderr + stderr = th_stderr.value if capture_stderr && capture_stderr != :merge_to_stdout else raise Timeout::Error end out_p.close if capture_stdout - err_p.close if capture_stderr + err_p.close if capture_stderr && capture_stderr != :merge_to_stdout Process.wait pid status = $? return stdout, stderr, status @@ -122,7 +122,7 @@ module Assertions public def assert_normal_exit(testsrc, message = '', opt = {}) - _, _, status = EnvUtil.invoke_ruby(%W'-W0', testsrc, true, true, opt) + out, _, status = EnvUtil.invoke_ruby(%W'-W0', testsrc, true, :merge_to_stdout, opt) pid = status.pid faildesc = proc do signo = status.termsig @@ -138,11 +138,10 @@ if !message.empty? full_message << message << "\n" end - if message.empty? - full_message << "pid #{pid} killed by #{sigdesc}" - else - message << "\n" if /\n\z/ !~ message - full_message << "pid #{pid} killed by #{sigdesc}\n#{message.gsub(/^/, '| ')}" + full_message << "pid #{pid} killed by #{sigdesc}" + if !out.empty? + out << "\n" if /\n\z/ !~ out + full_message << "\n#{out.gsub(/^/, '| ')}" end full_message end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/