mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
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>.
This commit is contained in:
parent
9ec8dc9c65
commit
a8d63ecdb8
Notes:
git
2025-03-12 17:27:21 +00:00
1 changed files with 6 additions and 3 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue