1# Copyright 2018 the V8 project authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5from . import base
6
7from testrunner.local import statusfile
8from testrunner.outproc import base as outproc
9
10class ForgiveTimeoutProc(base.TestProcProducer):
11  """Test processor passing tests and results through and forgiving timeouts."""
12  def __init__(self):
13    super(ForgiveTimeoutProc, self).__init__('no-timeout')
14
15  def _next_test(self, test):
16    subtest = self._create_subtest(test, 'no_timeout')
17    if subtest.expected_outcomes == outproc.OUTCOMES_PASS:
18      subtest.expected_outcomes = outproc.OUTCOMES_PASS_OR_TIMEOUT
19    elif subtest.expected_outcomes == outproc.OUTCOMES_FAIL:
20      subtest.expected_outcomes = outproc.OUTCOMES_FAIL_OR_TIMEOUT
21    elif statusfile.TIMEOUT not in subtest.expected_outcomes:
22      subtest.expected_outcomes = (
23          subtest.expected_outcomes + [statusfile.TIMEOUT])
24    self._send_test(subtest)
25
26  def _result_for(self, test, subtest, result):
27    self._send_result(test, result)
28