prevent memory allocation for GC tests

We observed test failures on test_latest_gc_info with random
order CI.
http://ci.rvm.jp/results/trunk-random1@phosphorus-docker/2998078l0ll

To solve it, use a pre-allocated hash object and rehearsal.
This commit is contained in:
Koichi Sasada 2020-06-12 17:28:58 +09:00
parent 1f4db23ac1
commit e2678781c7

View File

@ -145,11 +145,15 @@ class TestGc < Test::Unit::TestCase
assert_equal :newobj, GC.latest_gc_info[:gc_by]
eom
GC.latest_gc_info(h = {}) # allocate hash and rehearsal
GC.start
GC.start
assert_equal :force, GC.latest_gc_info[:major_by] if use_rgengc?
assert_equal :method, GC.latest_gc_info[:gc_by]
assert_equal true, GC.latest_gc_info[:immediate_sweep]
GC.start
GC.latest_gc_info(h)
assert_equal :force, h[:major_by] if use_rgengc?
assert_equal :method, h[:gc_by]
assert_equal true, h[:immediate_sweep]
GC.stress = true
assert_equal :force, GC.latest_gc_info[:major_by]