Skip to content

Commit c69d59e

Browse files
committed
Sync tool/lib/core_assertions.rb from master
It seems necessary to pass test-bundled-gems with REXML.
1 parent cf9a6c2 commit c69d59e

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

tool/lib/core_assertions.rb

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,11 @@ def message msg = nil, ending = nil, &default
7474
module CoreAssertions
7575
require_relative 'envutil'
7676
require 'pp'
77+
begin
78+
require '-test-/asan'
79+
rescue LoadError
80+
end
81+
7782
nil.pretty_inspect
7883

7984
def mu_pp(obj) #:nodoc:
@@ -152,6 +157,9 @@ def assert_no_memory_leak(args, prepare, code, message=nil, limit: 2.0, rss: fal
152157
pend 'assert_no_memory_leak may consider RJIT memory usage as leak' if defined?(RubyVM::RJIT) && RubyVM::RJIT.enabled?
153158
# For previous versions which implemented MJIT
154159
pend 'assert_no_memory_leak may consider MJIT memory usage as leak' if defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled?
160+
# ASAN has the same problem - its shadow memory greatly increases memory usage
161+
# (plus asan has better ways to detect memory leaks than this assertion)
162+
pend 'assert_no_memory_leak may consider ASAN memory usage as leak' if defined?(Test::ASAN) && Test::ASAN.enabled?
155163

156164
require_relative 'memory_status'
157165
raise Test::Unit::PendedError, "unsupported platform" unless defined?(Memory::Status)
@@ -817,7 +825,9 @@ def assert_linear_performance(seq, rehearsal: nil, pre: ->(n) {n})
817825
end
818826
times.compact!
819827
tmin, tmax = times.minmax
820-
tbase = 10 ** Math.log10(tmax * ([(tmax / tmin), 2].max ** 2)).ceil
828+
829+
# safe_factor * tmax * rehearsal_time_variance_factor(equals to 1 when variance is small)
830+
tbase = 10 * tmax * [(tmax / tmin) ** 2 / 4, 1].max
821831
info = "(tmin: #{tmin}, tmax: #{tmax}, tbase: #{tbase})"
822832

823833
seq.each do |i|

0 commit comments

Comments
 (0)