1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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
This commit is contained in:
akr 2008-05-22 02:40:50 +00:00
parent 9d27c792c2
commit a85b247171
3 changed files with 39 additions and 4 deletions

View file

@ -1,3 +1,8 @@
Thu May 22 11:39:59 2008 Tanaka Akira <akr@fsij.org>
* test/ruby/envutil.rb (assert_normal_exit): capture stdout and stderr
of the child process.
Thu May 22 08:28:49 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
* array.c (flatten): free memo hash table before raising exception.

View file

@ -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

View file

@ -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