File tree Expand file tree Collapse file tree 1 file changed +12
-7
lines changed Expand file tree Collapse file tree 1 file changed +12
-7
lines changed Original file line number Diff line number Diff line change @@ -51,20 +51,25 @@ module Concurrent
51
51
expect ( var . instance_variable_get ( :@storage ) . keys . size ) . to be == 1
52
52
end
53
53
54
+ # TODO this test is really bad, but better than nothing.
54
55
it 'does not leave values behind when bind is not used' do
55
- if rbx?
56
- pending ( 'fails on Rbx, possibly due to test dependency on GC' )
57
- end
58
- tries = Array . new ( 10 ) do
56
+ # TODO find out why it fails from the begging sometimes, hence the 3 tries
57
+ tries = Array . new ( 3 ) do
59
58
var = ThreadLocalVar . new ( 0 )
60
59
10 . times . map do |i |
61
60
Thread . new { var . value = i ; var . value }
62
61
end . each ( &:join )
63
62
var . value = 0
64
- GC . start
65
- var . instance_variable_get ( :@storage ) . keys . size == 1
63
+ # TODO find out why long sleep is necessary, does it take longer for threads to be collected?
64
+ sleep 1
65
+ if rbx?
66
+ GC . run true # force GC run
67
+ else
68
+ GC . start
69
+ end
70
+ var . instance_variable_get ( :@storage ) . keys . size
66
71
end
67
- expect ( tries . any? ) . to be_truthy
72
+ expect ( tries . any? { | v | v == 1 } ) . to be_truthy
68
73
end
69
74
end
70
75
end
You can’t perform that action at this time.
0 commit comments