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

ruby-changes:34131

From: akr <ko1@a...>
Date: Wed, 28 May 2014 23:06:40 +0900 (JST)
Subject: [ruby-changes:34131] akr:r46212 (trunk): * test/ruby/test_io.rb (test_flush_in_finalizer1): Use

akr	2014-05-28 23:06:28 +0900 (Wed, 28 May 2014)

  New Revision: 46212

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

  Log:
    * test/ruby/test_io.rb (test_flush_in_finalizer1): Use
      ObjectSpace.each_object to close files.
      GC.start is not reliable.

  Modified files:
    trunk/ChangeLog
    trunk/test/ruby/test_io.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 46211)
+++ ChangeLog	(revision 46212)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Wed May 28 23:04:35 2014  Tanaka Akira  <akr@f...>
+
+	* test/ruby/test_io.rb (test_flush_in_finalizer1): Use
+	  ObjectSpace.each_object to close files.
+	  GC.start is not reliable.
+
 Wed May 28 19:00:31 2014  Tanaka Akira  <akr@f...>
 
 	* lib/net/imap.rb (Net::IMAP#initialize): Close the opened socket when
Index: test/ruby/test_io.rb
===================================================================
--- test/ruby/test_io.rb	(revision 46211)
+++ test/ruby/test_io.rb	(revision 46212)
@@ -2358,6 +2358,7 @@ End https://github.com/ruby/ruby/blob/trunk/test/ruby/test_io.rb#L2358
       assert_nothing_raised(TypeError, bug3910) do
         500.times {
           f = File.open(path, "w")
+          f.instance_variable_set(:@test_flush_in_finalizer1, true)
           fds << f.fileno
           f.print "hoge"
         }
@@ -2365,7 +2366,11 @@ End https://github.com/ruby/ruby/blob/trunk/test/ruby/test_io.rb#L2366
       t
     }
   ensure
-    GC.start
+    ObjectSpace.each_object(File) {|f|
+      if f.instance_variables.include?(:@test_flush_in_finalizer1)
+        f.close
+      end
+    }
     t.close!
   end
 

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

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