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

test_rand.rb: improved assert_fork_status

* test/ruby/test_rand.rb (assert_fork_status): deal with errors
  from children.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59367 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2017-07-19 03:16:08 +00:00
parent 2cc3946d0e
commit 77f1277e1d

View file

@ -429,9 +429,20 @@ END
def assert_fork_status(n, mesg, &block)
IO.pipe do |r, w|
(1..n).map do
p1 = fork {w.puts(block.call.to_s)}
_, st = Process.waitpid2(p1)
assert_send([st, :success?], mesg)
st = desc = nil
IO.pipe do |re, we|
p1 = fork {
re.close
STDERR.reopen(we)
w.puts(block.call.to_s)
}
we.close
err = Thread.start {re.read}
_, st = Process.waitpid2(p1)
desc = FailDesc[st, mesg, err.value]
end
assert(!st.signaled?, desc)
assert(st.success?, mesg)
r.gets.strip
end
end