mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Narrow the tracing of object allocations to during each test
This commit is contained in:
parent
13939d61b4
commit
3839a8fe79
1 changed files with 28 additions and 28 deletions
|
@ -961,8 +961,11 @@ module MiniTest
|
||||||
}
|
}
|
||||||
|
|
||||||
leakchecker = LeakChecker.new
|
leakchecker = LeakChecker.new
|
||||||
|
if ENV["LEAK_CHECKER_TRACE_OBJECT_ALLOCATION"]
|
||||||
|
require "objspace"
|
||||||
|
trace = true
|
||||||
|
end
|
||||||
|
|
||||||
continuation = proc do
|
|
||||||
assertions = filtered_test_methods.map { |method|
|
assertions = filtered_test_methods.map { |method|
|
||||||
inst = suite.new method
|
inst = suite.new method
|
||||||
inst._assertions = 0
|
inst._assertions = 0
|
||||||
|
@ -970,7 +973,12 @@ module MiniTest
|
||||||
print "#{suite}##{method} = " if @verbose
|
print "#{suite}##{method} = " if @verbose
|
||||||
|
|
||||||
start_time = Time.now if @verbose
|
start_time = Time.now if @verbose
|
||||||
result = inst.run self
|
result =
|
||||||
|
if trace
|
||||||
|
ObjectSpace.trace_object_allocations {inst.run self}
|
||||||
|
else
|
||||||
|
inst.run self
|
||||||
|
end
|
||||||
|
|
||||||
print "%.2f s = " % (Time.now - start_time) if @verbose
|
print "%.2f s = " % (Time.now - start_time) if @verbose
|
||||||
print result
|
print result
|
||||||
|
@ -986,14 +994,6 @@ module MiniTest
|
||||||
return assertions.size, assertions.inject(0) { |sum, n| sum + n }
|
return assertions.size, assertions.inject(0) { |sum, n| sum + n }
|
||||||
end
|
end
|
||||||
|
|
||||||
if ENV["LEAK_CHECKER_TRACE_OBJECT_ALLOCATION"]
|
|
||||||
require "objspace"
|
|
||||||
ObjectSpace.trace_object_allocations(&continuation)
|
|
||||||
else
|
|
||||||
continuation.call
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
##
|
##
|
||||||
# Record the result of a single test. Makes it very easy to gather
|
# Record the result of a single test. Makes it very easy to gather
|
||||||
# information. Eg:
|
# information. Eg:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue