diff options
| author | Peter Zhu <peter@peterzhu.ca> | 2025-03-12 11:24:11 -0400 |
|---|---|---|
| committer | Peter Zhu <peter@peterzhu.ca> | 2025-03-12 13:27:03 -0400 |
| commit | a8d63ecdb82c33744c0d1fcfa362b0c7247e83c9 (patch) | |
| tree | 13d3f075b9f74f840d0f8627565552d805612fef /test/ruby | |
| parent | 9ec8dc9c6504e62c6a3ff6b111cee53f67d5508c (diff) | |
Fix flaky test_AREF_fstring_key
The code between the two ObjectSpace.count_objects could trigger a GC,
which could free string objects causing this test to fail.
We can see this failure on CI http://ci.rvm.jp/results/trunk-random2@ruby-sp2-noble-docker/5651016
TestHashOnly#test_AREF_fstring_key [test/ruby/test_hash.rb:1991]:
<197483> expected but was
<129689>.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/12916
Diffstat (limited to 'test/ruby')
| -rw-r--r-- | test/ruby/test_hash.rb | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/test/ruby/test_hash.rb b/test/ruby/test_hash.rb index 1e1b37f981..b6c18ea958 100644 --- a/test/ruby/test_hash.rb +++ b/test/ruby/test_hash.rb @@ -1986,9 +1986,12 @@ class TestHashOnly < Test::Unit::TestCase ObjectSpace.count_objects h = {"abc" => 1} - before = ObjectSpace.count_objects[:T_STRING] - 5.times{ h["abc"] } - assert_equal before, ObjectSpace.count_objects[:T_STRING] + + EnvUtil.without_gc do + before = ObjectSpace.count_objects[:T_STRING] + 5.times{ h["abc"] } + assert_equal before, ObjectSpace.count_objects[:T_STRING] + end end def test_AREF_fstring_key_default_proc |
