Fix flaky test_stat_heap_all
We only collect GC.stat_heap(nil, stat_heap_all) once, outside of the loop, but assert_equal could allocate objects which can cause a GC to run and cause stat_heap_all to be out-of-sync.
This commit is contained in:
parent
685a4e5be7
commit
1afcaa3e4b
@ -186,13 +186,12 @@ class TestGc < Test::Unit::TestCase
|
||||
omit "flaky with RJIT, which allocates objects itself" if defined?(RubyVM::RJIT) && RubyVM::RJIT.enabled?
|
||||
stat_heap_all = {}
|
||||
stat_heap = {}
|
||||
|
||||
2.times do
|
||||
# Initialize to prevent GC in future calls
|
||||
GC.stat_heap(0, stat_heap)
|
||||
GC.stat_heap(nil, stat_heap_all)
|
||||
end
|
||||
|
||||
GC::INTERNAL_CONSTANTS[:SIZE_POOL_COUNT].times do |i|
|
||||
GC.stat_heap(nil, stat_heap_all)
|
||||
GC.stat_heap(i, stat_heap)
|
||||
|
||||
# Remove keys that can vary between invocations
|
||||
|
Loading…
x
Reference in New Issue
Block a user