diff options
author | k0kubun <k0kubun@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-11-01 04:20:26 +0000 |
---|---|---|
committer | k0kubun <k0kubun@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-11-01 04:20:26 +0000 |
commit | e31864a8a0508a66b71a643c95741199e65c81a2 (patch) | |
tree | 00a894fd90a730a9bde5029354a01563e5ddeb07 /test/win32ole/test_win32ole_event.rb | |
parent | 0b16758b049d10715e3861ae208c65fcf290013e (diff) | |
download | ruby-e31864a8a0508a66b71a643c95741199e65c81a2.tar.gz |
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
Diffstat (limited to 'test/win32ole/test_win32ole_event.rb')
-rw-r--r-- | test/win32ole/test_win32ole_event.rb | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/test/win32ole/test_win32ole_event.rb b/test/win32ole/test_win32ole_event.rb index e23097e2e1..a1546da4a2 100644 --- a/test/win32ole/test_win32ole_event.rb +++ b/test/win32ole/test_win32ole_event.rb @@ -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 |