v8/tools/testrunner/testproc/base.py
Michal Majewski 501413b9b9 [test] Implemented indicators as processors
Added simple system tests for different progress indicators.

Bug: v8:6917
Change-Id: I906ddfd06e82cc19d3b2210e09457456be00309b
Cq-Include-Trybots: luci.v8.try:v8_linux64_fyi_rel_ng
Reviewed-on: https://chromium-review.googlesource.com/852495
Commit-Queue: Michał Majewski <majeski@google.com>
Reviewed-by: Michael Achenbach <machenbach@chromium.org>
Cr-Commit-Position: refs/heads/master@{#50406}
2018-01-08 13:08:40 +00:00

84 lines
2.1 KiB
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.
class TestProc(object):
def __init__(self):
self._prev_proc = None
self._next_proc = None
def connect_to(self, next_proc):
next_proc._prev_proc = self
self._next_proc = next_proc
def next_test(self, test):
raise NotImplementedError()
def result_for(self, test, result, is_last):
raise NotImplementedError()
def heartbeat(self):
if self._prev_proc:
self._prev_proc.heartbeat()
### Communication
def _send_test(self, test):
return self._next_proc.next_test(test)
def _send_result(self, test, result, is_last=True):
return self._prev_proc.result_for(test, result, is_last=is_last)
class TestProcObserver(TestProc):
def next_test(self, test):
self._on_next_test(test)
self._send_test(test)
def result_for(self, test, result, is_last):
self._on_result_for(test, result, is_last)
self._send_result(test, result, is_last)
def heartbeat(self):
self._on_heartbeat()
super(TestProcObserver, self).heartbeat()
def _on_next_test(self, test):
pass
def _on_result_for(self, test, result, is_last):
pass
def _on_heartbeat(self):
pass
class TestProcProducer(TestProc):
def __init__(self, name):
super(TestProcProducer, self).__init__()
self._name = name
def next_test(self, test):
return self._next_test(test)
def result_for(self, subtest, result, is_last):
test = self._get_subtest_origin(subtest)
self._result_for(test, subtest, result, is_last)
### Implementation
def _next_test(self, test):
raise NotImplementedError()
def _result_for(self, test, subtest, result, is_last):
raise NotImplementedError()
### Managing subtests
def _create_subtest(self, test, subtest_id):
return test.create_subtest(self, '%s-%s' % (self._name, subtest_id))
def _get_subtest_origin(self, subtest):
while subtest.processor and subtest.processor is not self:
subtest = subtest.origin
return subtest.origin