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:
parent
2cc3946d0e
commit
77f1277e1d
1 changed files with 14 additions and 3 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue