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

ruby-changes:66615

From: Nobuyoshi <ko1@a...>
Date: Sun, 27 Jun 2021 21:20:25 +0900 (JST)
Subject: [ruby-changes:66615] 3839a8fe79 (master): Narrow the tracing of object allocations to during each test

https://git.ruby-lang.org/ruby.git/commit/?id=3839a8fe79

From 3839a8fe79a3ec95ff9bf78ad1fd95953d600876 Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Sun, 27 Jun 2021 21:13:37 +0900
Subject: Narrow the tracing of object allocations to during each test

---
 tool/lib/minitest/unit.rb | 50 +++++++++++++++++++++++------------------------
 1 file changed, 25 insertions(+), 25 deletions(-)

diff --git a/tool/lib/minitest/unit.rb b/tool/lib/minitest/unit.rb
index ec6d635..2cda29a 100644
--- a/tool/lib/minitest/unit.rb
+++ b/tool/lib/minitest/unit.rb
@@ -961,37 +961,37 @@ module MiniTest https://github.com/ruby/ruby/blob/trunk/tool/lib/minitest/unit.rb#L961
       }
 
       leakchecker = LeakChecker.new
+      if ENV["LEAK_CHECKER_TRACE_OBJECT_ALLOCATION"]
+        require "objspace"
+        trace = true
+      end
 
-      continuation = proc do
-        assertions = filtered_test_methods.map { |method|
-          inst = suite.new method
-          inst._assertions = 0
-
-          print "#{suite}##{method} = " if @verbose
-
-          start_time = Time.now if @verbose
-          result = inst.run self
+      assertions = filtered_test_methods.map { |method|
+        inst = suite.new method
+        inst._assertions = 0
 
-          print "%.2f s = " % (Time.now - start_time) if @verbose
-          print result
-          puts if @verbose
-          $stdout.flush
+        print "#{suite}##{method} = " if @verbose
 
-          unless defined?(RubyVM::JIT) && RubyVM::JIT.enabled? # compiler process is wrongly considered as leak
-            leakchecker.check("#{inst.class}\##{inst.__name__}")
+        start_time = Time.now if @verbose
+        result =
+          if trace
+            ObjectSpace.trace_object_allocations {inst.run self}
+          else
+            inst.run self
           end
 
-          inst._assertions
-        }
-        return assertions.size, assertions.inject(0) { |sum, n| sum + n }
-      end
+        print "%.2f s = " % (Time.now - start_time) if @verbose
+        print result
+        puts if @verbose
+        $stdout.flush
 
-      if ENV["LEAK_CHECKER_TRACE_OBJECT_ALLOCATION"]
-        require "objspace"
-        ObjectSpace.trace_object_allocations(&continuation)
-      else
-        continuation.call
-      end
+        unless defined?(RubyVM::JIT) && RubyVM::JIT.enabled? # compiler process is wrongly considered as leak
+          leakchecker.check("#{inst.class}\##{inst.__name__}")
+        end
+
+        inst._assertions
+      }
+      return assertions.size, assertions.inject(0) { |sum, n| sum + n }
     end
 
     ##
-- 
cgit v1.1


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

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