Commit a3015a6a authored by Brian Quinlan's avatar Brian Quinlan

Better reporting of test failures on Windows.

parent dfd7eb0b
...@@ -75,15 +75,27 @@ class Call(object): ...@@ -75,15 +75,27 @@ class Call(object):
def _wait_on_event(self, handle): def _wait_on_event(self, handle):
if sys.platform.startswith('win'): if sys.platform.startswith('win'):
# WaitForSingleObject returns 0 if handle is signaled.
r = ctypes.windll.kernel32.WaitForSingleObject(handle, 60 * 1000) r = ctypes.windll.kernel32.WaitForSingleObject(handle, 60 * 1000)
assert r == 0 if r != 0:
message = (
'WaitForSingleObject({}, ...) failed with {}, '
'GetLastError() = {}'.format(
handle, r, ctypes.GetLastError()))
logging.critical(message)
assert False, message
else: else:
self.CALL_LOCKS[handle].wait() self.CALL_LOCKS[handle].wait()
def _signal_event(self, handle): def _signal_event(self, handle):
if sys.platform.startswith('win'): if sys.platform.startswith('win'):
r = ctypes.windll.kernel32.SetEvent(handle) r = ctypes.windll.kernel32.SetEvent(handle) # Returns 0 on failure.
assert r != 0 if r == 0:
message = (
'SetEvent({}) failed with {}, GetLastError() = {}'.format(
handle, r, ctypes.GetLastError()))
logging.critical(message)
assert False, message
else: else:
self.CALL_LOCKS[handle].set() self.CALL_LOCKS[handle].set()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment