Disable GC checks for Ruby auto_ptr test

This commit is contained in:
William S Fulton 2020-01-31 22:45:46 +00:00
parent e321ee30f0
commit a9731251a4
1 changed files with 12 additions and 28 deletions

View File

@ -4,40 +4,24 @@ require 'swig_assert'
require 'li_std_auto_ptr'
def gc_check(expected_count)
# GC.start(full_mark: true, immediate_sweep: true)
GC.start
# GC is not reliably run, skip check
# swig_assert_equal_simple(expected_count, Li_std_auto_ptr::Klass::getTotal_count())
end
k1 = Li_std_auto_ptr::makeKlassAutoPtr("first")
k2 = Li_std_auto_ptr::makeKlassAutoPtr("second")
swig_assert_equal_simple(Li_std_auto_ptr::Klass::getTotal_count(), 2)
swig_assert_equal_simple(2, Li_std_auto_ptr::Klass::getTotal_count())
gc_check(2)
k1 = nil
GC.start
# GC can need a few runs to actually collect the object.
100.times do ||
next if Li_std_auto_ptr::Klass::getTotal_count() == 2
swig_assert_equal_simple(Li_std_auto_ptr::Klass::getTotal_count(), 1)
break
end
gc_check(1)
swig_assert_equal_simple(k2.getLabel(), "second")
if Li_std_auto_ptr::Klass::getTotal_count() != 1
STDERR.puts "GC failed to collect the first object, count still #{Li_std_auto_ptr::Klass::getTotal_count()}"
# Skip the rest of the test as it's not going to work correctly anyhow.
exit
end
gc_check(1)
k2 = nil
GC.start
gc_check(0)
100.times do ||
next if Li_std_auto_ptr::Klass::getTotal_count() == 1
swig_assert_equal_simple(Li_std_auto_ptr::Klass::getTotal_count(), 0)
break
end
if Li_std_auto_ptr::Klass::getTotal_count() != 0
STDERR.puts "GC failed to collect the second object, count still #{Li_std_auto_ptr::Klass::getTotal_count()}"
end