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

ruby-changes:32139

From: nobu <ko1@a...>
Date: Sun, 15 Dec 2013 07:34:47 +0900 (JST)
Subject: [ruby-changes:32139] nobu:r44218 (trunk): test_process.rb: handshake

nobu	2013-12-15 07:34:43 +0900 (Sun, 15 Dec 2013)

  New Revision: 44218

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=44218

  Log:
    test_process.rb: handshake
    
    * test/ruby/test_process.rb: handshake by pipe instead of sleep.

  Modified files:
    trunk/test/ruby/test_process.rb
Index: test/ruby/test_process.rb
===================================================================
--- test/ruby/test_process.rb	(revision 44217)
+++ test/ruby/test_process.rb	(revision 44218)
@@ -1186,10 +1186,14 @@ class TestProcess < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_process.rb#L1186
     return unless Signal.list.include?("QUIT")
 
     with_tmpchdir do
-      write_file("foo", "sleep 30")
-      pid = spawn(RUBY, "foo")
-      Thread.new { sleep 1; Process.kill(:SIGQUIT, pid) }
-      Process.wait(pid)
+      write_file("foo", "puts;STDOUT.flush;sleep 30")
+      pid = nil
+      IO.pipe do |r, w|
+        pid = spawn(RUBY, "foo", out: w)
+        w.close
+        Thread.new { r.read(1); Process.kill(:SIGQUIT, pid) }
+        Process.wait(pid)
+      end
       t = Time.now
       s = $?
       assert_equal([false, true, false],
@@ -1336,10 +1340,17 @@ class TestProcess < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_process.rb#L1340
     end
     signal_received = []
     Signal.trap(:CHLD)  { signal_received << true }
-    pid = fork { sleep 0.1; exit }
-    Thread.start { raise }
+    pid = nil
+    IO.pipe do |r, w|
+      pid = fork { r.read(1); exit }
+      Thread.start { raise }
+      w.puts
+    end
     Process.wait pid
-    sleep 0.1
+    10.times do
+      break unless signal_received.empty?
+      sleep 0.01
+    end
     assert_equal [true], signal_received, " [ruby-core:19744]"
   rescue NotImplementedError, ArgumentError
   ensure

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

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