Fix flaky test_latest_gc_info_need_major_by
It's possible for a GC to run between the calls of GC.latest_gc_info, which would cause the test to fail. We can disable GC so that GC only triggers manually.
This commit is contained in:
parent
c1fecc5eab
commit
1b82d63462
@ -374,15 +374,17 @@ class TestGc < Test::Unit::TestCase
|
|||||||
objects.append(100.times.map { '*' })
|
objects.append(100.times.map { '*' })
|
||||||
end
|
end
|
||||||
|
|
||||||
# We need to ensure that no GC gets ran before the call to GC.start since
|
EnvUtil.without_gc do
|
||||||
# it would trigger a major GC. Assertions could allocate objects and
|
# We need to ensure that no GC gets ran before the call to GC.start since
|
||||||
# trigger a GC so we don't run assertions until we perform the major GC.
|
# it would trigger a major GC. Assertions could allocate objects and
|
||||||
need_major_by = GC.latest_gc_info(:need_major_by)
|
# trigger a GC so we don't run assertions until we perform the major GC.
|
||||||
GC.start(full_mark: false) # should be upgraded to major
|
need_major_by = GC.latest_gc_info(:need_major_by)
|
||||||
major_by = GC.latest_gc_info(:major_by)
|
GC.start(full_mark: false) # should be upgraded to major
|
||||||
|
major_by = GC.latest_gc_info(:major_by)
|
||||||
|
|
||||||
assert_not_nil(need_major_by)
|
assert_not_nil(need_major_by)
|
||||||
assert_not_nil(major_by)
|
assert_not_nil(major_by)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_latest_gc_info_weak_references_count
|
def test_latest_gc_info_weak_references_count
|
||||||
|
Loading…
x
Reference in New Issue
Block a user