test/win32ole/test_win32ole_event.rb: wait longer
for unstable spec. I added r64963 but it couldn't rescue: https://ci.appveyor.com/project/ruby/ruby/builds/19451743/job/hg0tyoxbacrrlnsr Since #test_on_event is especially unstable, https://ci.appveyor.com/project/ruby/ruby/builds/19337514/job/0wp2oe9dkr9gt1bi https://ci.appveyor.com/project/ruby/ruby/builds/19451743/job/hg0tyoxbacrrlnsr this commit lets it sleep longer as needed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65030 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
54e99c7cd8
commit
6c415d0163
@ -63,12 +63,26 @@ if defined?(WIN32OLE_EVENT)
|
|||||||
@sql = "SELECT * FROM __InstanceModificationEvent WITHIN 1 WHERE TargetInstance ISA 'Win32_LocalTime'"
|
@sql = "SELECT * FROM __InstanceModificationEvent WITHIN 1 WHERE TargetInstance ISA 'Win32_LocalTime'"
|
||||||
end
|
end
|
||||||
|
|
||||||
def message_loop
|
def message_loop(watch_ivar = nil)
|
||||||
|
if watch_ivar
|
||||||
|
orig_ivar = instance_variable_get(watch_ivar)
|
||||||
|
end
|
||||||
|
|
||||||
2.times do
|
2.times do
|
||||||
WIN32OLE_EVENT.message_loop
|
WIN32OLE_EVENT.message_loop
|
||||||
sleep 1
|
sleep 1
|
||||||
end
|
end
|
||||||
sleep 1
|
|
||||||
|
if watch_ivar
|
||||||
|
# wait until event is proceeded
|
||||||
|
tries = 0
|
||||||
|
while tries < 5 && instance_variable_get(watch_ivar) == orig_ivar
|
||||||
|
seconds = 2 ** tries # sleep at most 31s in total
|
||||||
|
$stderr.puts "test_win32ole_event.rb: sleeping #{seconds}s until #{watch_ivar} is changed from #{orig_ivar.inspect}..."
|
||||||
|
sleep(seconds)
|
||||||
|
tries += 1
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def default_handler(event, *args)
|
def default_handler(event, *args)
|
||||||
@ -109,7 +123,7 @@ if defined?(WIN32OLE_EVENT)
|
|||||||
exec_notification_query_async
|
exec_notification_query_async
|
||||||
ev = WIN32OLE_EVENT.new(@sws, 'ISWbemSinkEvents')
|
ev = WIN32OLE_EVENT.new(@sws, 'ISWbemSinkEvents')
|
||||||
ev.on_event {|*args| default_handler(*args)}
|
ev.on_event {|*args| default_handler(*args)}
|
||||||
message_loop
|
message_loop(:@event)
|
||||||
assert_match(/OnObjectReady/, @event)
|
assert_match(/OnObjectReady/, @event)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user