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

ruby-changes:31547

From: nobu <ko1@a...>
Date: Sun, 10 Nov 2013 03:12:48 +0900 (JST)
Subject: [ruby-changes:31547] nobu:r43626 (trunk): test_objectspace.rb: run in separate process

nobu	2013-11-10 03:12:39 +0900 (Sun, 10 Nov 2013)

  New Revision: 43626

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

  Log:
    test_objectspace.rb: run in separate process
    
    * test/ruby/test_objectspace.rb (TestObjectSpace#test_finalizer): run
      in separate process so that finalizers run at termination certainly.

  Modified files:
    trunk/test/ruby/test_objectspace.rb
Index: test/ruby/test_objectspace.rb
===================================================================
--- test/ruby/test_objectspace.rb	(revision 43625)
+++ test/ruby/test_objectspace.rb	(revision 43626)
@@ -64,27 +64,20 @@ End https://github.com/ruby/ruby/blob/trunk/test/ruby/test_objectspace.rb#L64
       !b
     END
     assert_raise(ArgumentError) { ObjectSpace.define_finalizer([], Object.new) }
-    fin = Struct.new(:garbage).new
-    class << fin
-      alias call garbage=
-    end
-    assertion = proc do
-      fin.garbage = nil
-      assert_nothing_raised(ArgumentError) {
-        EnvUtil.under_gc_stress do
-          3.times do
-            ObjectSpace.define_finalizer([], fin)
-          end
-          GC.start
+
+    code = proc do |priv|
+      <<-"CODE"
+      fin = Object.new
+      class << fin
+        #{priv}def call(id)
+          puts "finalized"
         end
-      }
-      assert_not_nil(fin.garbage)
-    end
-    assertion.call
-    class << fin
-      private :call
+      end
+      ObjectSpace.define_finalizer([], fin)
+      CODE
     end
-    assertion.call
+    assert_in_out_err([], code[""], ["finalized"])
+    assert_in_out_err([], code["private "], ["finalized"])
   end
 
   def test_each_object

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

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