Bug 1352463 - Define WPT timeouts on the test type level; r=jgraham

Certain test types have a need for other defaults than the
wpttest.DEFAULT_TIMEOUT and wpttest.LONG_TIMEOUT values.  This patch
changes wptrunner to define default- and long timeouts on a test type
level.  This allows a test type to override the default durations defined
in the abstract Test.default_timeout and Test.long_timeout.

Concrete classes, such as ReftestTest and WdspecTest, may override these
class properties.

MozReview-Commit-ID: IS6df5vuIDC

--HG--
extra : rebase_source : a3f37d4524902f2b0d54e14126b57da327f0ec06
This commit is contained in:
Andreas Tolfsen 2017-03-31 17:38:35 +01:00
Родитель 545cdbc891
Коммит 6564760558
2 изменённых файлов: 15 добавлений и 11 удалений

Просмотреть файл

@ -92,8 +92,8 @@ class EqualTimeChunker(TestChunker):
by_dir[test_dir] = PathData(test_dir)
data = by_dir[test_dir]
time = sum(wpttest.DEFAULT_TIMEOUT if test.timeout !=
"long" else wpttest.LONG_TIMEOUT for test in tests)
time = sum(test.default_timeout if test.timeout !=
"long" else test.long_timeout for test in tests)
data.time += time
total_time += time
data.tests.append((test_type, test_path, tests))

Просмотреть файл

@ -2,9 +2,6 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
DEFAULT_TIMEOUT = 10 # seconds
LONG_TIMEOUT = 60 # seconds
import os
import mozinfo
@ -99,17 +96,21 @@ class RunInfo(dict):
class Test(object):
result_cls = None
subtest_result_cls = None
test_type = None
default_timeout = 10 # seconds
long_timeout = 60 # seconds
def __init__(self, tests_root, url, inherit_metadata, test_metadata,
timeout=DEFAULT_TIMEOUT, path=None, protocol="http"):
timeout=None, path=None, protocol="http"):
self.tests_root = tests_root
self.url = url
self._inherit_metadata = inherit_metadata
self._test_metadata = test_metadata
self.timeout = timeout
self.timeout = timeout if timeout is not None else self.default_timeout
self.path = path
self.environment = {"protocol": protocol, "prefs": self.prefs}
@ -118,7 +119,7 @@ class Test(object):
@classmethod
def from_manifest(cls, manifest_item, inherit_metadata, test_metadata):
timeout = LONG_TIMEOUT if manifest_item.timeout == "long" else DEFAULT_TIMEOUT
timeout = cls.long_timeout if manifest_item.timeout == "long" else cls.default_timeout
protocol = "https" if hasattr(manifest_item, "https") and manifest_item.https else "http"
return cls(manifest_item.source_file.tests_root,
manifest_item.url,
@ -249,8 +250,7 @@ class ReftestTest(Test):
test_type = "reftest"
def __init__(self, tests_root, url, inherit_metadata, test_metadata, references,
timeout=DEFAULT_TIMEOUT, path=None, viewport_size=None,
dpi=None, protocol="http"):
timeout=None, path=None, viewport_size=None, dpi=None, protocol="http"):
Test.__init__(self, tests_root, url, inherit_metadata, test_metadata, timeout,
path, protocol)
@ -270,7 +270,7 @@ class ReftestTest(Test):
nodes=None,
references_seen=None):
timeout = LONG_TIMEOUT if manifest_test.timeout == "long" else DEFAULT_TIMEOUT
timeout = cls.long_timeout if manifest_test.timeout == "long" else cls.default_timeout
if nodes is None:
nodes = {}
@ -334,10 +334,14 @@ class ReftestTest(Test):
class WdspecTest(Test):
result_cls = WdspecResult
subtest_result_cls = WdspecSubtestResult
test_type = "wdspec"
default_timeout = 10
long_timeout = 60
manifest_test_cls = {"reftest": ReftestTest,
"testharness": TestharnessTest,