Skip to content

Commit a973125

Browse files
committed
Disable GC checks for Ruby auto_ptr test
1 parent e321ee3 commit a973125

File tree

1 file changed

+12
-28
lines changed

1 file changed

+12
-28
lines changed

Examples/test-suite/ruby/li_std_auto_ptr_runme.rb

Lines changed: 12 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,40 +4,24 @@
44

55
require 'li_std_auto_ptr'
66

7+
def gc_check(expected_count)
8+
# GC.start(full_mark: true, immediate_sweep: true)
9+
GC.start
10+
# GC is not reliably run, skip check
11+
# swig_assert_equal_simple(expected_count, Li_std_auto_ptr::Klass::getTotal_count())
12+
end
13+
714
k1 = Li_std_auto_ptr::makeKlassAutoPtr("first")
815
k2 = Li_std_auto_ptr::makeKlassAutoPtr("second")
9-
swig_assert_equal_simple(Li_std_auto_ptr::Klass::getTotal_count(), 2)
16+
swig_assert_equal_simple(2, Li_std_auto_ptr::Klass::getTotal_count())
1017

18+
gc_check(2)
1119
k1 = nil
12-
GC.start
13-
14-
# GC can need a few runs to actually collect the object.
15-
100.times do ||
16-
next if Li_std_auto_ptr::Klass::getTotal_count() == 2
17-
18-
swig_assert_equal_simple(Li_std_auto_ptr::Klass::getTotal_count(), 1)
19-
break
20-
end
20+
gc_check(1)
2121

2222
swig_assert_equal_simple(k2.getLabel(), "second")
23-
24-
if Li_std_auto_ptr::Klass::getTotal_count() != 1
25-
STDERR.puts "GC failed to collect the first object, count still #{Li_std_auto_ptr::Klass::getTotal_count()}"
26-
27-
# Skip the rest of the test as it's not going to work correctly anyhow.
28-
exit
29-
end
23+
gc_check(1)
3024

3125
k2 = nil
32-
GC.start
33-
34-
100.times do ||
35-
next if Li_std_auto_ptr::Klass::getTotal_count() == 1
26+
gc_check(0)
3627

37-
swig_assert_equal_simple(Li_std_auto_ptr::Klass::getTotal_count(), 0)
38-
break
39-
end
40-
41-
if Li_std_auto_ptr::Klass::getTotal_count() != 0
42-
STDERR.puts "GC failed to collect the second object, count still #{Li_std_auto_ptr::Klass::getTotal_count()}"
43-
end

0 commit comments

Comments
 (0)