diff options
author | Peter Zhu <[email protected]> | 2025-03-10 15:47:57 -0400 |
---|---|---|
committer | Peter Zhu <[email protected]> | 2025-03-11 11:44:07 -0400 |
commit | e51411ff1fa38b296020529b51241b96d2c15b54 (patch) | |
tree | 4d19a60f03822fd85cc2ff8d2d96a3395878c9e0 /test/ruby | |
parent | 497f409ba402ee2207f71f6998fe996433370107 (diff) |
Fix flaky test_latest_gc_info_need_major_by
The test could flake because a major GC could be triggered due to allocation
for caches or other things, which would cause the test to fail.
Diffstat (limited to 'test/ruby')
-rw-r--r-- | test/ruby/test_gc.rb | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/test/ruby/test_gc.rb b/test/ruby/test_gc.rb index b0794c0845..7ae05e206f 100644 --- a/test/ruby/test_gc.rb +++ b/test/ruby/test_gc.rb @@ -356,13 +356,14 @@ class TestGc < Test::Unit::TestCase 3.times { GC.start } assert_nil GC.latest_gc_info(:need_major_by) - # allocate objects until need_major_by is set or major GC happens - objects = [] - while GC.latest_gc_info(:need_major_by).nil? - objects.append(100.times.map { '*' }) - end - EnvUtil.without_gc do + # allocate objects until need_major_by is set or major GC happens + objects = [] + while GC.latest_gc_info(:need_major_by).nil? + objects.append(100.times.map { '*' }) + GC.start(full_mark: false) + end + # We need to ensure that no GC gets ran before the call to GC.start since # it would trigger a major GC. Assertions could allocate objects and # trigger a GC so we don't run assertions until we perform the major GC. |