Bug 1474581 - Add support for external scripts in wpt .any.js tests in jstests harness; r=jgraham

This commit is contained in:
Ms2ger 2018-07-11 17:52:37 +02:00
Родитель b6aa690249
Коммит 2773d9005a
2 изменённых файлов: 18 добавлений и 3 удалений

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

@ -369,8 +369,19 @@ def load_wpt_tests(requested_paths, excluded_paths, debug):
os.path.join(here, "testharnessreport.js"), os.path.join(here, "testharnessreport.js"),
] ]
def resolve(test_path, script):
if script.startswith("/"):
return os.path.join(wpt, script[1:])
return os.path.join(test_path, script)
return [ return [
RefTestCase(wpt, test_path, extra_helper_paths=extra_helper_paths, wpt=test) RefTestCase(
wpt,
test_path,
extra_helper_paths=extra_helper_paths + [resolve(test_path, s) for s in test.scripts],
wpt=test
)
for test_path, test_type, test in loader.iter_tests() for test_path, test_type, test in loader.iter_tests()
] ]

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

@ -265,12 +265,13 @@ class TestharnessTest(Test):
def __init__(self, tests_root, url, inherit_metadata, test_metadata, def __init__(self, tests_root, url, inherit_metadata, test_metadata,
timeout=None, path=None, protocol="http", testdriver=False, timeout=None, path=None, protocol="http", testdriver=False,
jsshell=False): jsshell=False, scripts=None):
Test.__init__(self, tests_root, url, inherit_metadata, test_metadata, timeout, Test.__init__(self, tests_root, url, inherit_metadata, test_metadata, timeout,
path, protocol) path, protocol)
self.testdriver = testdriver self.testdriver = testdriver
self.jsshell = jsshell self.jsshell = jsshell
self.scripts = scripts or []
@classmethod @classmethod
def from_manifest(cls, manifest_item, inherit_metadata, test_metadata): def from_manifest(cls, manifest_item, inherit_metadata, test_metadata):
@ -278,6 +279,8 @@ class TestharnessTest(Test):
protocol = "https" if hasattr(manifest_item, "https") and manifest_item.https else "http" protocol = "https" if hasattr(manifest_item, "https") and manifest_item.https else "http"
testdriver = manifest_item.testdriver if hasattr(manifest_item, "testdriver") else False testdriver = manifest_item.testdriver if hasattr(manifest_item, "testdriver") else False
jsshell = manifest_item.jsshell if hasattr(manifest_item, "jsshell") else False jsshell = manifest_item.jsshell if hasattr(manifest_item, "jsshell") else False
script_metadata = manifest_item.source_file.script_metadata or []
scripts = [v for (k, v) in script_metadata if k == b"script"]
return cls(manifest_item.source_file.tests_root, return cls(manifest_item.source_file.tests_root,
manifest_item.url, manifest_item.url,
inherit_metadata, inherit_metadata,
@ -286,7 +289,8 @@ class TestharnessTest(Test):
path=manifest_item.source_file.path, path=manifest_item.source_file.path,
protocol=protocol, protocol=protocol,
testdriver=testdriver, testdriver=testdriver,
jsshell=jsshell) jsshell=jsshell,
scripts=scripts)
@property @property
def id(self): def id(self):