Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tools: enable ctrl-c for parallel tests #277

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions tools/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ def __init__(self, cases, flaky_tests_mode):
self.total = len(cases)
self.failed = [ ]
self.crashed = 0
self.terminate = False
self.lock = threading.Lock()
self.shutdown_event = threading.Event()

def PrintFailureHeader(self, test):
if test.IsNegative():
Expand Down Expand Up @@ -101,17 +101,19 @@ def Run(self, tasks):
for thread in threads:
# Use a timeout so that signals (ctrl-c) will be processed.
thread.join(timeout=10000000)
except (KeyboardInterrupt, SystemExit), e:
self.shutdown_event.set()
except Exception, e:
# If there's an exception we schedule an interruption for any
# remaining threads.
self.terminate = True
self.shutdown_event.set()
# ...and then reraise the exception to bail out
raise
self.Done()
return not self.failed

def RunSingle(self, parallel, thread_id):
while not self.terminate:
while not self.shutdown_event.is_set():
try:
test = self.parallel_queue.get_nowait()
except Empty:
Expand All @@ -131,9 +133,8 @@ def RunSingle(self, parallel, thread_id):
output = case.Run()
case.duration = (datetime.now() - start)
except IOError, e:
assert self.terminate
return
if self.terminate:
if self.shutdown_event.is_set():
return
self.lock.acquire()
if output.UnexpectedOutput():
Expand Down