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

ruby-changes:34150

From: akr <ko1@a...>
Date: Thu, 29 May 2014 22:38:44 +0900 (JST)
Subject: [ruby-changes:34150] akr:r46231 (trunk): test/test_pty.rb: Close fds.

akr	2014-05-29 22:38:39 +0900 (Thu, 29 May 2014)

  New Revision: 46231

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

  Log:
    test/test_pty.rb: Close fds.

  Modified files:
    trunk/test/test_pty.rb
Index: test/test_pty.rb
===================================================================
--- test/test_pty.rb	(revision 46230)
+++ test/test_pty.rb	(revision 46231)
@@ -12,19 +12,26 @@ class TestPTY < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/test_pty.rb#L12
   RUBY = EnvUtil.rubybin
 
   def test_spawn_without_block
-    r, _, pid = PTY.spawn(RUBY, '-e', 'puts "a"')
+    r, w, pid = PTY.spawn(RUBY, '-e', 'puts "a"')
   rescue RuntimeError
     skip $!
   else
     assert_equal("a\r\n", r.gets)
   ensure
+    r.close if r
+    w.close if w
     Process.wait pid if pid
   end
 
   def test_spawn_with_block
     PTY.spawn(RUBY, '-e', 'puts "b"') {|r,w,pid|
-      assert_equal("b\r\n", r.gets)
-      Process.wait(pid)
+      begin
+        assert_equal("b\r\n", r.gets)
+      ensure
+        r.close
+        w.close
+        Process.wait(pid)
+      end
     }
   rescue RuntimeError
     skip $!
@@ -33,8 +40,13 @@ class TestPTY < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/test_pty.rb#L40
   def test_commandline
     commandline = Shellwords.join([RUBY, '-e', 'puts "foo"'])
     PTY.spawn(commandline) {|r,w,pid|
-      assert_equal("foo\r\n", r.gets)
-      Process.wait(pid)
+      begin
+        assert_equal("foo\r\n", r.gets)
+      ensure
+        r.close
+        w.close
+        Process.wait(pid)
+      end
     }
   rescue RuntimeError
     skip $!
@@ -42,8 +54,13 @@ class TestPTY < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/test_pty.rb#L54
 
   def test_argv0
     PTY.spawn([RUBY, "argv0"], '-e', 'puts "bar"') {|r,w,pid|
-      assert_equal("bar\r\n", r.gets)
-      Process.wait(pid)
+      begin
+        assert_equal("bar\r\n", r.gets)
+      ensure
+        r.close
+        w.close
+        Process.wait(pid)
+      end
     }
   rescue RuntimeError
     skip $!
@@ -209,9 +226,14 @@ class TestPTY < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/test_pty.rb#L226
       assert(s.close_on_exec?)
     }
     PTY.spawn(RUBY, '-e', '') {|r, w, pid|
-      assert(r.close_on_exec?)
-      assert(w.close_on_exec?)
-      Process.wait(pid)
+      begin
+        assert(r.close_on_exec?)
+        assert(w.close_on_exec?)
+      ensure
+        r.close
+        w.close
+        Process.wait(pid)
+      end
     }
   rescue RuntimeError
     skip $!

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

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