Narrow the tracing of object allocations to during each test
This commit is contained in:
parent
13939d61b4
commit
3839a8fe79
@ -961,37 +961,37 @@ module MiniTest
|
|||||||
}
|
}
|
||||||
|
|
||||||
leakchecker = LeakChecker.new
|
leakchecker = LeakChecker.new
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
print "%.2f s = " % (Time.now - start_time) if @verbose
|
|
||||||
print result
|
|
||||||
puts if @verbose
|
|
||||||
$stdout.flush
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
if ENV["LEAK_CHECKER_TRACE_OBJECT_ALLOCATION"]
|
if ENV["LEAK_CHECKER_TRACE_OBJECT_ALLOCATION"]
|
||||||
require "objspace"
|
require "objspace"
|
||||||
ObjectSpace.trace_object_allocations(&continuation)
|
trace = true
|
||||||
else
|
|
||||||
continuation.call
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
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 =
|
||||||
|
if trace
|
||||||
|
ObjectSpace.trace_object_allocations {inst.run self}
|
||||||
|
else
|
||||||
|
inst.run self
|
||||||
|
end
|
||||||
|
|
||||||
|
print "%.2f s = " % (Time.now - start_time) if @verbose
|
||||||
|
print result
|
||||||
|
puts if @verbose
|
||||||
|
$stdout.flush
|
||||||
|
|
||||||
|
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
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
Loading…
x
Reference in New Issue
Block a user