From e7d578bf587050c08aaf9f9ac1b71ce69be044d7 Mon Sep 17 00:00:00 2001 From: nobu Date: Sun, 30 Aug 2015 06:46:16 +0000 Subject: [PATCH] test_win32ole_event.rb: skip 80041008 * test/win32ole/test_win32ole_event.rb (exec_notification_query_async): skip error with OLE error code:80041008, which seems to occur when logging in as a non admistrator user. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51725 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/win32ole/test_win32ole_event.rb | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/test/win32ole/test_win32ole_event.rb b/test/win32ole/test_win32ole_event.rb index 86004cdad7..a1ad9b1025 100644 --- a/test/win32ole/test_win32ole_event.rb +++ b/test/win32ole/test_win32ole_event.rb @@ -91,7 +91,7 @@ if defined?(WIN32OLE_EVENT) end def test_s_new_loop - @wmi.ExecNotificationQueryAsync(@sws, @sql) + exec_notification_query_async ev = WIN32OLE_EVENT.new(@sws) ev.on_event {|*args| default_handler(*args)} message_loop @@ -104,7 +104,7 @@ if defined?(WIN32OLE_EVENT) end def test_on_event - @wmi.ExecNotificationQueryAsync(@sws, @sql) + exec_notification_query_async ev = WIN32OLE_EVENT.new(@sws, 'ISWbemSinkEvents') ev.on_event {|*args| default_handler(*args)} message_loop @@ -112,7 +112,7 @@ if defined?(WIN32OLE_EVENT) end def test_on_event_symbol - @wmi.ExecNotificationQueryAsync(@sws, @sql) + exec_notification_query_async ev = WIN32OLE_EVENT.new(@sws) ev.on_event(:OnObjectReady) {|*args| handler1 @@ -121,6 +121,14 @@ if defined?(WIN32OLE_EVENT) assert_equal("handler1", @event1) end + private + def exec_notification_query_async + @wmi.ExecNotificationQueryAsync(@sws, @sql) + rescue => e + # No administrator privilege? + skip if /OLE error code:80041008 in SWbemServicesEx/ =~ e.message + raise + end end end