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
5151 expect ( var . instance_variable_get ( :@storage ) . keys . size ) . to be == 1
5252 end
5353
54+ # TODO this test is really bad, but better than nothing.
5455 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
5958 var = ThreadLocalVar . new ( 0 )
6059 10 . times . map do |i |
6160 Thread . new { var . value = i ; var . value }
6261 end . each ( &:join )
6362 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
6671 end
67- expect ( tries . any? ) . to be_truthy
72+ expect ( tries . any? { | v | v == 1 } ) . to be_truthy
6873 end
6974 end
7075 end
You can’t perform that action at this time.
0 commit comments