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

ruby-changes:29390

From: nobu <ko1@a...>
Date: Thu, 20 Jun 2013 00:57:27 +0900 (JST)
Subject: [ruby-changes:29390] nobu:r41442 (trunk): test_signal.rb: use standard fds

nobu	2013-06-20 00:57:14 +0900 (Thu, 20 Jun 2013)

  New Revision: 41442

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

  Log:
    test_signal.rb: use standard fds
    
    * test/ruby/test_signal.rb (test_exit_action): use IO.popen and
      standard file descriptors instead of fd 3 and 4, which is not
      available on Windows.

  Modified files:
    trunk/test/ruby/test_signal.rb

Index: test/ruby/test_signal.rb
===================================================================
--- test/ruby/test_signal.rb	(revision 41441)
+++ test/ruby/test_signal.rb	(revision 41442)
@@ -40,22 +40,23 @@ class TestSignal < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_signal.rb#L40
     Process.respond_to?(:pgroup) # for mswin32
 
   def test_exit_action
-    begin
-      r, w = IO.pipe
-      r0, w0 = IO.pipe
-      pid = Process.spawn(EnvUtil.rubybin, '-e', <<-'End', 3=>w, 4=>r0)
-        w = IO.new(3, "w")
-        r0 = IO.new(4, "r")
-        Signal.trap(:USR1, "EXIT")
-        w.syswrite("a")
+    if Signal.list[sig = "USR1"]
+      term = :TERM
+    else
+      sig = "INT"
+      term = :KILL
+    end
+    IO.popen([EnvUtil.rubybin, '-e', <<-"End"], 'r+') do |io|
+        Signal.trap(:#{sig}, "EXIT")
+        STDOUT.syswrite("a")
         Thread.start { sleep(2) }
-        r0.sysread(4096)
+        STDIN.sysread(4096)
       End
-      r.sysread(1)
+      pid = io.pid
+      io.sysread(1)
       sleep 0.1
       assert_nothing_raised("[ruby-dev:26128]") {
-        Process.kill(:USR1, pid)
-        term = :TERM
+        Process.kill(term, pid)
         begin
           Timeout.timeout(3) {
             Process.waitpid pid
@@ -69,11 +70,6 @@ class TestSignal < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_signal.rb#L70
           raise
         end
       }
-    ensure
-      r.close
-      w.close
-      r0.close
-      w0.close
     end
   end if Process.respond_to?(:kill)
 

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

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