1478c30786
Bug: v8:6917 Change-Id: I5cca65111141f32f8b9f241a9f482d09e1b54655 Reviewed-on: https://chromium-review.googlesource.com/893982 Commit-Queue: Michał Majewski <majeski@google.com> Reviewed-by: Michael Achenbach <machenbach@chromium.org> Cr-Commit-Position: refs/heads/master@{#50987}
37 lines
994 B
Python
37 lines
994 B
Python
# Copyright 2018 the V8 project authors. All rights reserved.
|
|
# Use of this source code is governed by a BSD-style license that can be
|
|
# found in the LICENSE file.
|
|
|
|
import signal
|
|
|
|
from . import base
|
|
|
|
|
|
class SignalProc(base.TestProcObserver):
|
|
def __init__(self):
|
|
super(SignalProc, self).__init__()
|
|
self._ctrlc = False
|
|
|
|
def setup(self, *args, **kwargs):
|
|
super(SignalProc, self).setup(*args, **kwargs)
|
|
# It should be called after processors are chained together to not loose
|
|
# catched signal.
|
|
signal.signal(signal.SIGINT, self._on_ctrlc)
|
|
|
|
def _on_next_test(self, _test):
|
|
self._on_event()
|
|
|
|
def _on_result_for(self, _test, _result):
|
|
self._on_event()
|
|
|
|
def _on_ctrlc(self, _signum, _stack_frame):
|
|
if not self._ctrlc:
|
|
print '>>> Ctrl-C detected, waiting for ongoing tests to finish...'
|
|
self._ctrlc = True
|
|
else:
|
|
print '>>> Pressing Ctrl-C again won\'t make this faster...'
|
|
|
|
def _on_event(self):
|
|
if self._ctrlc:
|
|
self.stop()
|