v8/tools/testrunner/testproc/timeout.py
Michal Majewski 7557be5a06 Reland "[test] Move timeout control to timeout processor"
This is a reland of 4de2be999d.

Original change's description:
> [test] Move timeout control to timeout processor
> 
> Bug: v8:6917
> Change-Id: I03be38be952f0d59eb20fa98102ef09ca795de40
> Reviewed-on: https://chromium-review.googlesource.com/883446
> Commit-Queue: Michał Majewski <majeski@google.com>
> Reviewed-by: Michael Achenbach <machenbach@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#50848}

Bug: v8:6917
Change-Id: I52798af84991d4815910e9da5f4837329cdb3c96
Reviewed-on: https://chromium-review.googlesource.com/885765
Reviewed-by: Michael Achenbach <machenbach@chromium.org>
Commit-Queue: Michał Majewski <majeski@google.com>
Cr-Commit-Position: refs/heads/master@{#50870}
2018-01-25 14:09:44 +00:00

27 lines
665 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 time
from . import base
# TODO(majeski): Signal handler
class TimeoutProc(base.TestProcObserver):
def __init__(self, duration_sec):
super(TimeoutProc, self).__init__()
self._duration_sec = duration_sec
self._start = time.time()
def _on_next_test(self, test):
self._on_event()
def _on_result_for(self, test, result):
self._on_event()
def _on_event(self):
if not self.is_stopped:
if time.time() - self._start > self._duration_sec:
self.stop()