From 77f1277e1d154aa7858e9584559d648b1df2865d Mon Sep 17 00:00:00 2001 From: nobu Date: Wed, 19 Jul 2017 03:16:08 +0000 Subject: [PATCH] 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 --- test/ruby/test_rand.rb | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/test/ruby/test_rand.rb b/test/ruby/test_rand.rb index 79befa8f04..7b4ae07ee9 100644 --- a/test/ruby/test_rand.rb +++ b/test/ruby/test_rand.rb @@ -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