[前][次][番号順一覧][スレッド一覧]

ruby-changes:47252

From: nobu <ko1@a...>
Date: Wed, 19 Jul 2017 12:16:17 +0900 (JST)
Subject: [ruby-changes:47252] nobu:r59367 (trunk): test_rand.rb: improved assert_fork_status

nobu	2017-07-19 12:16:08 +0900 (Wed, 19 Jul 2017)

  New Revision: 59367

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=59367

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

  Modified files:
    trunk/test/ruby/test_rand.rb
Index: test/ruby/test_rand.rb
===================================================================
--- test/ruby/test_rand.rb	(revision 59366)
+++ test/ruby/test_rand.rb	(revision 59367)
@@ -429,9 +429,20 @@ END https://github.com/ruby/ruby/blob/trunk/test/ruby/test_rand.rb#L429
   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

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]