From 7299c8c0f165247853fac2fe337e7c2678e653c9 Mon Sep 17 00:00:00 2001 From: Peter Zhu Date: Tue, 11 Jul 2023 14:09:48 -0400 Subject: [PATCH] Try to fix flaky GC test assert_not_nil could allocate objects which may trigger the major GC, so don't run the assertions until the major GC has been ran. --- test/ruby/test_gc.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/test/ruby/test_gc.rb b/test/ruby/test_gc.rb index 0f4a13211e..7650c68eca 100644 --- a/test/ruby/test_gc.rb +++ b/test/ruby/test_gc.rb @@ -262,9 +262,12 @@ class TestGc < Test::Unit::TestCase objects.append(100.times.map { '*' }) end - assert_not_nil GC.latest_gc_info(:need_major_by) + need_major_by = GC.latest_gc_info(:need_major_by) GC.start(full_mark: false) # should be upgraded to major - assert_not_nil GC.latest_gc_info(:major_by) + major_by = GC.latest_gc_info(:major_by) + + assert_not_nil(need_major_by) + assert_not_nil(major_by) end def test_stress_compile_send