From f546fe15d547472f60c4a2d2857321b3c5084f0f Mon Sep 17 00:00:00 2001 From: Peter Zhu Date: Wed, 18 Oct 2023 11:01:43 +0200 Subject: [PATCH] Loosen assertion for flaky weak references test --- test/ruby/test_gc.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/ruby/test_gc.rb b/test/ruby/test_gc.rb index 567e7b5d80458b..b22f5b8a65ed4d 100644 --- a/test/ruby/test_gc.rb +++ b/test/ruby/test_gc.rb @@ -327,7 +327,8 @@ def test_latest_gc_info_weak_references_count # Run full GC again to collect stats about weak references GC.start - assert_equal(0, wmap.size) + # Sometimes the WeakMap has one element, which might be held on by registers. + assert_operator(wmap.size, :<=, 1) assert_operator(GC.latest_gc_info(:weak_references_count), :<=, before_weak_references_count - count + error_tolerance) assert_operator(GC.latest_gc_info(:retained_weak_references_count), :<=, before_retained_weak_references_count - count + error_tolerance)