diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-05-22 02:40:50 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-05-22 02:40:50 +0000 |
commit | a85b247171373d079d98eeef42c6014980062609 (patch) | |
tree | e7186a3a991eacf48d45765839d56d1e207a8ecc /test/ruby | |
parent | 9d27c792c25174237ad4d47e5d409efd72d57342 (diff) | |
download | ruby-a85b247171373d079d98eeef42c6014980062609.tar.gz |
* test/ruby/envutil.rb (assert_normal_exit): capture stdout and stderr
of the child process.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16520 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby')
-rw-r--r-- | test/ruby/envutil.rb | 26 | ||||
-rw-r--r-- | test/ruby/test_continuation.rb | 12 |
2 files changed, 34 insertions, 4 deletions
diff --git a/test/ruby/envutil.rb b/test/ruby/envutil.rb index bfecb60084..910b475232 100644 --- a/test/ruby/envutil.rb +++ b/test/ruby/envutil.rb @@ -72,9 +72,16 @@ module Test module Assertions public def assert_normal_exit(testsrc, message = '') - IO.popen([EnvUtil.rubybin, '-W0'], 'w') {|io| - io.write testsrc - } + in_c, in_p = IO.pipe + out_p, out_c = IO.pipe + pid = spawn(EnvUtil.rubybin, '-W0', STDIN=>in_c, STDOUT=>out_c, STDERR=>out_c) + in_c.close + out_c.close + in_p.write testsrc + in_p.close + msg = out_p.read + out_p.close + Process.wait pid status = $? faildesc = nil if status.signaled? @@ -84,9 +91,20 @@ module Test if signame sigdesc = "SIG#{signame} (#{sigdesc})" end - full_message = build_message(message, "killed by ?", sigdesc) + if msg.empty? + full_message = build_message(message, "killed by ?", sigdesc) + else + msg << "\n" if /\n\z/ !~ msg + full_message = build_message(message, "killed by ?\n?", sigdesc, + AssertionMessage::Literal.new(msg.gsub(/^/, '| '))) + end end assert_block(full_message) { !status.signaled? } + ensure + in_c.close if in_c && !in_c.closed? + in_p.close if in_p && !in_p.closed? + out_c.close if out_c && !out_c.closed? + out_p.close if out_p && !out_p.closed? end end end diff --git a/test/ruby/test_continuation.rb b/test/ruby/test_continuation.rb index 09787c1589..f8302abdc1 100644 --- a/test/ruby/test_continuation.rb +++ b/test/ruby/test_continuation.rb @@ -51,5 +51,17 @@ class TestContinuation < Test::Unit::TestCase c.call } end + + def test_ary_flatten + assert_normal_exit %q{ + require 'continuation' + n = 0 + o = Object.new + def o.to_ary() callcc {|k| $k = k; [1,2,3]} end + [10,20,o,30,o,40].flatten.inspect + n += 1 + $k.call if n < 100 + }, '[ruby-dev:34798]' + end end |