1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

test_win32ole_event.rb: retry #test_s_new_loop with sleep

It seems to fail randomly:
https://ci.appveyor.com/project/ruby/ruby/builds/19963142/job/8gaxepksa0i3b998

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65480 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
k0kubun 2018-11-01 04:20:26 +00:00
parent 0b16758b04
commit e31864a8a0

View file

@ -117,7 +117,10 @@ if defined?(WIN32OLE_EVENT)
message_loop
GC.start
end
assert_match(/OnObjectReady/, @event)
# @event randomly becomes "OnCompleted" here. Try to wait until it matches.
# https://ci.appveyor.com/project/ruby/ruby/builds/19963142/job/8gaxepksa0i3b998
assert_match_with_retries(/OnObjectReady/, :@event)
end
def test_on_event
@ -147,6 +150,19 @@ if defined?(WIN32OLE_EVENT)
end
raise
end
def assert_match_with_retries(regexp, ivarname)
ivar = instance_variable_get(ivarname)
tries = 0
while tries < 5 && !ivar.match(regexp)
$stderr.puts "test_win32ole_event.rb: retrying until #{ivarname} matches #{regexp} (tries: #{tries})..."
sleep(2 ** tries) # sleep at most 31s in total
ivar = instance_variable_get(ivarname)
end
assert_match(regexp, ivar)
end
end
end