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

ruby-changes:34146

From: akr <ko1@a...>
Date: Thu, 29 May 2014 21:07:44 +0900 (JST)
Subject: [ruby-changes:34146] akr:r46227 (trunk): test/fileutils/test_fileutils.rb: Close fds.

akr	2014-05-29 21:07:39 +0900 (Thu, 29 May 2014)

  New Revision: 46227

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

  Log:
    test/fileutils/test_fileutils.rb: Close fds.

  Modified files:
    trunk/test/fileutils/test_fileutils.rb
Index: test/fileutils/test_fileutils.rb
===================================================================
--- test/fileutils/test_fileutils.rb	(revision 46226)
+++ test/fileutils/test_fileutils.rb	(revision 46227)
@@ -13,15 +13,16 @@ class TestFileUtils < Test::Unit::TestCa https://github.com/ruby/ruby/blob/trunk/test/fileutils/test_fileutils.rb#L13
 
   def assert_output_lines(expected, fu = self, message=nil)
     old = fu.instance_variable_get(:@fileutils_output)
-    read, write = IO.pipe
-    fu.instance_variable_set(:@fileutils_output, write)
-    th = Thread.new { read.read }
+    IO.pipe {|read, write|
+      fu.instance_variable_set(:@fileutils_output, write)
+      th = Thread.new { read.read }
 
-    yield
+      yield
 
-    write.close
-    lines = th.value.lines.map {|l| l.chomp }
-    assert_equal(expected, lines)
+      write.close
+      lines = th.value.lines.map {|l| l.chomp }
+      assert_equal(expected, lines)
+    }
   ensure
     fu.instance_variable_set(:@fileutils_output, old) if old
   end

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

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