Commit b6d66386 authored by Stephen McGruer's avatar Stephen McGruer Committed by Commit Bot

Roll WPT internal tools to 66af89be218a1c81e89ad786104bf2866d006422

Bug: None
Change-Id: Ib66c86639734a88269c75ecfd08c8c4bbc1396fe
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2220452
Auto-Submit: Stephen McGruer <smcgruer@chromium.org>
Commit-Queue: Robert Ma <robertma@chromium.org>
Reviewed-by: default avatarRobert Ma <robertma@chromium.org>
Cr-Commit-Position: refs/heads/master@{#773163}
parent 97b0f657
...@@ -22,7 +22,7 @@ Local Modifications: None ...@@ -22,7 +22,7 @@ Local Modifications: None
Name: web-platform-tests - Test Suites for Web Platform specifications Name: web-platform-tests - Test Suites for Web Platform specifications
Short Name: wpt Short Name: wpt
URL: https://github.com/web-platform-tests/wpt/ URL: https://github.com/web-platform-tests/wpt/
Version: 616f425e074db57f29e8c8559945fc4bfacd8393 Version: 66af89be218a1c81e89ad786104bf2866d006422
License: LICENSES FOR W3C TEST SUITES (https://www.w3.org/Consortium/Legal/2008/03-bsd-license.html) License: LICENSES FOR W3C TEST SUITES (https://www.w3.org/Consortium/Legal/2008/03-bsd-license.html)
License File: wpt/wpt/LICENSE.md License File: wpt/wpt/LICENSE.md
Security Critical: no Security Critical: no
......
...@@ -9,7 +9,7 @@ cd $DIR ...@@ -9,7 +9,7 @@ cd $DIR
TARGET_DIR=$DIR/wpt TARGET_DIR=$DIR/wpt
REMOTE_REPO="https://github.com/web-platform-tests/wpt.git" REMOTE_REPO="https://github.com/web-platform-tests/wpt.git"
WPT_HEAD=616f425e074db57f29e8c8559945fc4bfacd8393 WPT_HEAD=66af89be218a1c81e89ad786104bf2866d006422
function clone { function clone {
# Remove existing repo if already exists. # Remove existing repo if already exists.
......
...@@ -467,6 +467,7 @@ def check_parsed(repo_root, path, f): ...@@ -467,6 +467,7 @@ def check_parsed(repo_root, path, f):
if (source_file.type != "support" and if (source_file.type != "support" and
not source_file.name_is_reference and not source_file.name_is_reference and
not source_file.name_is_tentative and
not source_file.spec_links): not source_file.spec_links):
return [rules.MissingLink.error(path)] return [rules.MissingLink.error(path)]
...@@ -652,7 +653,7 @@ broken_python_metadata = re.compile(br"#\s*META:") ...@@ -652,7 +653,7 @@ broken_python_metadata = re.compile(br"#\s*META:")
def check_global_metadata(value): def check_global_metadata(value):
# type: (str) -> Iterable[Tuple[Type[rules.Rule], Tuple[Any, ...]]] # type: (str) -> Iterable[Tuple[Type[rules.Rule], Tuple[Any, ...]]]
global_values = {item.strip() for item in value.split(b",") if item.strip()} global_values = {item.strip().decode("utf8") for item in value.split(b",") if item.strip()}
# TODO: this could check for duplicates and such # TODO: this could check for duplicates and such
for global_value in global_values: for global_value in global_values:
......
...@@ -212,7 +212,7 @@ class TestharnessTest(URLManifestItem): ...@@ -212,7 +212,7 @@ class TestharnessTest(URLManifestItem):
if self.quic is not None: if self.quic is not None:
rv[-1]["quic"] = self.quic rv[-1]["quic"] = self.quic
if self.script_metadata: if self.script_metadata:
rv[-1]["script_metadata"] = [(k.decode('utf8'), v.decode('utf8')) for (k,v) in self.script_metadata] rv[-1]["script_metadata"] = [(k, v) for (k,v) in self.script_metadata]
return rv return rv
......
...@@ -7,6 +7,7 @@ from multiprocessing import Pool, cpu_count ...@@ -7,6 +7,7 @@ from multiprocessing import Pool, cpu_count
from six import ( from six import (
PY3, PY3,
binary_type, binary_type,
ensure_text,
iteritems, iteritems,
itervalues, itervalues,
string_types, string_types,
...@@ -175,12 +176,14 @@ class Manifest(object): ...@@ -175,12 +176,14 @@ class Manifest(object):
to_update = [] to_update = []
for source_file, update in tree: for source_file_or_path, update in tree:
if not update: if not update:
assert isinstance(source_file, (binary_type, text_type)) assert isinstance(source_file_or_path, (binary_type, text_type))
deleted.remove(tuple(source_file.split(os.path.sep))) path = ensure_text(source_file_or_path)
deleted.remove(tuple(path.split(os.path.sep)))
else: else:
assert not isinstance(source_file, bytes) assert not isinstance(source_file_or_path, (binary_type, text_type))
source_file = source_file_or_path
rel_path_parts = source_file.rel_path_parts rel_path_parts = source_file.rel_path_parts
assert isinstance(rel_path_parts, tuple) assert isinstance(rel_path_parts, tuple)
......
...@@ -2,7 +2,7 @@ import hashlib ...@@ -2,7 +2,7 @@ import hashlib
import re import re
import os import os
from collections import deque from collections import deque
from six import binary_type, iteritems, text_type from six import binary_type, ensure_text, iteritems, text_type
from six.moves.urllib.parse import urljoin from six.moves.urllib.parse import urljoin
from fnmatch import fnmatch from fnmatch import fnmatch
...@@ -56,9 +56,9 @@ def replace_end(s, old, new): ...@@ -56,9 +56,9 @@ def replace_end(s, old, new):
def read_script_metadata(f, regexp): def read_script_metadata(f, regexp):
# type: (BinaryIO, Pattern[bytes]) -> Iterable[Tuple[bytes, bytes]] # type: (BinaryIO, Pattern[bytes]) -> Iterable[Tuple[Text, Text]]
""" """
Yields any metadata (pairs of bytestrings) from the file-like object `f`, Yields any metadata (pairs of strings) from the file-like object `f`,
as specified according to a supplied regexp. as specified according to a supplied regexp.
`regexp` - Regexp containing two groups containing the metadata name and `regexp` - Regexp containing two groups containing the metadata name and
...@@ -70,25 +70,25 @@ def read_script_metadata(f, regexp): ...@@ -70,25 +70,25 @@ def read_script_metadata(f, regexp):
if not m: if not m:
break break
yield (m.groups()[0], m.groups()[1]) yield (m.groups()[0].decode("utf8"), m.groups()[1].decode("utf8"))
_any_variants = { _any_variants = {
b"window": {"suffix": ".any.html"}, "window": {"suffix": ".any.html"},
b"serviceworker": {"force_https": True}, "serviceworker": {"force_https": True},
b"sharedworker": {}, "sharedworker": {},
b"dedicatedworker": {"suffix": ".any.worker.html"}, "dedicatedworker": {"suffix": ".any.worker.html"},
b"worker": {"longhand": {b"dedicatedworker", b"sharedworker", b"serviceworker"}}, "worker": {"longhand": {"dedicatedworker", "sharedworker", "serviceworker"}},
b"jsshell": {"suffix": ".any.js"}, "jsshell": {"suffix": ".any.js"},
} # type: Dict[bytes, Dict[str, Any]] } # type: Dict[Text, Dict[Text, Any]]
def get_any_variants(item): def get_any_variants(item):
# type: (bytes) -> Set[bytes] # type: (Text) -> Set[Text]
""" """
Returns a set of variants (bytestrings) defined by the given keyword. Returns a set of variants (strings) defined by the given keyword.
""" """
assert isinstance(item, binary_type), item assert isinstance(item, text_type), item
variant = _any_variants.get(item, None) variant = _any_variants.get(item, None)
if variant is None: if variant is None:
...@@ -98,46 +98,46 @@ def get_any_variants(item): ...@@ -98,46 +98,46 @@ def get_any_variants(item):
def get_default_any_variants(): def get_default_any_variants():
# type: () -> Set[bytes] # type: () -> Set[Text]
""" """
Returns a set of variants (bytestrings) that will be used by default. Returns a set of variants (strings) that will be used by default.
""" """
return set({b"window", b"dedicatedworker"}) return set({"window", "dedicatedworker"})
def parse_variants(value): def parse_variants(value):
# type: (bytes) -> Set[bytes] # type: (Text) -> Set[Text]
""" """
Returns a set of variants (bytestrings) defined by a comma-separated value. Returns a set of variants (strings) defined by a comma-separated value.
""" """
assert isinstance(value, binary_type), value assert isinstance(value, text_type), value
if value == b"": if value == "":
return get_default_any_variants() return get_default_any_variants()
globals = set() globals = set()
for item in value.split(b","): for item in value.split(","):
item = item.strip() item = item.strip()
globals |= get_any_variants(item) globals |= get_any_variants(item)
return globals return globals
def global_suffixes(value): def global_suffixes(value):
# type: (bytes) -> Set[Tuple[bytes, bool]] # type: (Text) -> Set[Tuple[Text, bool]]
""" """
Yields tuples of the relevant filename suffix (a string) and whether the Yields tuples of the relevant filename suffix (a string) and whether the
variant is intended to run in a JS shell, for the variants defined by the variant is intended to run in a JS shell, for the variants defined by the
given comma-separated value. given comma-separated value.
""" """
assert isinstance(value, binary_type), value assert isinstance(value, text_type), value
rv = set() rv = set()
global_types = parse_variants(value) global_types = parse_variants(value)
for global_type in global_types: for global_type in global_types:
variant = _any_variants[global_type] variant = _any_variants[global_type]
suffix = variant.get("suffix", ".any.%s.html" % global_type.decode("utf-8")) suffix = variant.get("suffix", ".any.%s.html" % global_type)
rv.add((suffix, global_type == b"jsshell")) rv.add((suffix, global_type == "jsshell"))
return rv return rv
...@@ -190,24 +190,21 @@ class SourceFile(object): ...@@ -190,24 +190,21 @@ class SourceFile(object):
("css", "CSS2", "archive"), ("css", "CSS2", "archive"),
("css", "common")} # type: Set[Tuple[bytes, ...]] ("css", "common")} # type: Set[Tuple[bytes, ...]]
def __init__(self, tests_root, rel_path, url_base, hash=None, contents=None): def __init__(self, tests_root, rel_path_str, url_base, hash=None, contents=None):
# type: (AnyStr, AnyStr, Text, Optional[Text], Optional[bytes]) -> None # type: (AnyStr, AnyStr, Text, Optional[Text], Optional[bytes]) -> None
"""Object representing a file in a source tree. """Object representing a file in a source tree.
:param tests_root: Path to the root of the source tree :param tests_root: Path to the root of the source tree
:param rel_path: File path relative to tests_root :param rel_path_str: File path relative to tests_root
:param url_base: Base URL used when converting file paths to urls :param url_base: Base URL used when converting file paths to urls
:param contents: Byte array of the contents of the file or ``None``. :param contents: Byte array of the contents of the file or ``None``.
""" """
rel_path = ensure_text(rel_path_str)
assert not os.path.isabs(rel_path), rel_path assert not os.path.isabs(rel_path), rel_path
if os.name == "nt": if os.name == "nt":
# do slash normalization on Windows # do slash normalization on Windows
if isinstance(rel_path, binary_type): rel_path = rel_path.replace(u"/", u"\\")
rel_path = rel_path.replace(b"/", b"\\")
else:
rel_path = rel_path.replace(u"/", u"\\")
dir_path, filename = os.path.split(rel_path) dir_path, filename = os.path.split(rel_path)
name, ext = os.path.splitext(filename) name, ext = os.path.splitext(filename)
...@@ -218,13 +215,13 @@ class SourceFile(object): ...@@ -218,13 +215,13 @@ class SourceFile(object):
meta_flags = name.split(".")[1:] meta_flags = name.split(".")[1:]
self.tests_root = tests_root # type: Union[bytes, Text] self.tests_root = ensure_text(tests_root) # type: Text
self.rel_path = rel_path # type: Union[bytes, Text] self.rel_path = rel_path # type: Text
self.dir_path = dir_path # type: Union[bytes, Text] self.dir_path = dir_path # type: Text
self.filename = filename # type: Union[bytes, Text] self.filename = filename # type: Text
self.name = name # type: Union[bytes, Text] self.name = name # type: Text
self.ext = ext # type: Union[bytes, Text] self.ext = ext # type: Text
self.type_flag = type_flag # type: Optional[Union[bytes, Text]] self.type_flag = type_flag # type: Optional[Text]
self.meta_flags = meta_flags # type: Union[List[bytes], List[Text]] self.meta_flags = meta_flags # type: Union[List[bytes], List[Text]]
self.url_base = url_base self.url_base = url_base
self.contents = contents self.contents = contents
...@@ -282,7 +279,7 @@ class SourceFile(object): ...@@ -282,7 +279,7 @@ class SourceFile(object):
@cached_property @cached_property
def path(self): def path(self):
# type: () -> Union[bytes, Text] # type: () -> Text
return os.path.join(self.tests_root, self.rel_path) return os.path.join(self.tests_root, self.rel_path)
@cached_property @cached_property
...@@ -410,6 +407,15 @@ class SourceFile(object): ...@@ -410,6 +407,15 @@ class SourceFile(object):
# type: () -> bool # type: () -> bool
return self.type_flag == "crash" or "crashtests" in self.dir_path.split(os.path.sep) return self.type_flag == "crash" or "crashtests" in self.dir_path.split(os.path.sep)
@property
def name_is_tentative(self):
# type: () -> bool
"""Check if the file name matches the conditions for the file to be a
tentative file.
See https://web-platform-tests.org/writing-tests/file-names.html#test-features"""
return "tentative" in self.meta_flags
@property @property
def markup_type(self): def markup_type(self):
# type: () -> Optional[Text] # type: () -> Optional[Text]
...@@ -462,7 +468,7 @@ class SourceFile(object): ...@@ -462,7 +468,7 @@ class SourceFile(object):
@cached_property @cached_property
def script_metadata(self): def script_metadata(self):
# type: () -> Optional[List[Tuple[bytes, bytes]]] # type: () -> Optional[List[Tuple[Text, Text]]]
if self.name_is_worker or self.name_is_multi_global or self.name_is_window: if self.name_is_worker or self.name_is_multi_global or self.name_is_window:
regexp = js_meta_re regexp = js_meta_re
elif self.name_is_webdriver: elif self.name_is_webdriver:
...@@ -479,7 +485,7 @@ class SourceFile(object): ...@@ -479,7 +485,7 @@ class SourceFile(object):
"""The timeout of a test or reference file. "long" if the file has an extended timeout """The timeout of a test or reference file. "long" if the file has an extended timeout
or None otherwise""" or None otherwise"""
if self.script_metadata: if self.script_metadata:
if any(m == (b"timeout", b"long") for m in self.script_metadata): if any(m == ("timeout", "long") for m in self.script_metadata):
return "long" return "long"
if self.root is None: if self.root is None:
...@@ -641,8 +647,8 @@ class SourceFile(object): ...@@ -641,8 +647,8 @@ class SourceFile(object):
script_metadata = self.script_metadata script_metadata = self.script_metadata
assert script_metadata is not None assert script_metadata is not None
for (key, value) in script_metadata: for (key, value) in script_metadata:
if key == b"variant": if key == "variant":
rv.append(value.decode("utf-8")) rv.append(value)
else: else:
for element in self.variant_nodes: for element in self.variant_nodes:
if "content" in element.attrib: if "content" in element.attrib:
...@@ -691,7 +697,7 @@ class SourceFile(object): ...@@ -691,7 +697,7 @@ class SourceFile(object):
(`script_metadata()`). (`script_metadata()`).
""" """
if self.script_metadata: if self.script_metadata:
if any(m == (b"quic", b"true") for m in self.script_metadata): if any(m == ("quic", "true") for m in self.script_metadata):
return True return True
if self.root is None: if self.root is None:
...@@ -864,11 +870,11 @@ class SourceFile(object): ...@@ -864,11 +870,11 @@ class SourceFile(object):
)] )]
elif self.name_is_multi_global: elif self.name_is_multi_global:
globals = b"" globals = u""
script_metadata = self.script_metadata script_metadata = self.script_metadata
assert script_metadata is not None assert script_metadata is not None
for (key, value) in script_metadata: for (key, value) in script_metadata:
if key == b"global": if key == "global":
globals = value globals = value
break break
...@@ -992,9 +998,9 @@ class SourceFile(object): ...@@ -992,9 +998,9 @@ class SourceFile(object):
if drop_cached and "__cached_properties__" in self.__dict__: if drop_cached and "__cached_properties__" in self.__dict__:
cached_properties = self.__dict__["__cached_properties__"] cached_properties = self.__dict__["__cached_properties__"]
for key in cached_properties: for prop in cached_properties:
if key in self.__dict__: if prop in self.__dict__:
del self.__dict__[key] del self.__dict__[prop]
del self.__dict__["__cached_properties__"] del self.__dict__["__cached_properties__"]
return rv return rv
...@@ -226,12 +226,12 @@ class GitIgnoreCache(CacheFile, MutableMapping): # type: ignore ...@@ -226,12 +226,12 @@ class GitIgnoreCache(CacheFile, MutableMapping): # type: ignore
def check_valid(self, data): def check_valid(self, data):
# type: (Dict[Any, Any]) -> Dict[Any, Any] # type: (Dict[Any, Any]) -> Dict[Any, Any]
ignore_path = os.path.join(self.tests_root, b".gitignore") ignore_path = os.path.join(self.tests_root, ".gitignore")
mtime = os.path.getmtime(ignore_path) mtime = os.path.getmtime(ignore_path)
if data.get(b"/gitignore_file") != [ignore_path, mtime]: if data.get("/gitignore_file") != [ignore_path, mtime]:
self.modified = True self.modified = True
data = {} data = {}
data[b"/gitignore_file"] = [ignore_path, mtime] data["/gitignore_file"] = [ignore_path, mtime]
return data return data
def __contains__(self, key): def __contains__(self, key):
......
...@@ -178,9 +178,9 @@ class HtmlWrapperHandler(WrapperHandler): ...@@ -178,9 +178,9 @@ class HtmlWrapperHandler(WrapperHandler):
def check_exposure(self, request): def check_exposure(self, request):
if self.global_type: if self.global_type:
globals = b"" globals = u""
for (key, value) in self._get_metadata(request): for (key, value) in self._get_metadata(request):
if key == b"global": if key == "global":
globals = value globals = value
break break
...@@ -189,23 +189,23 @@ class HtmlWrapperHandler(WrapperHandler): ...@@ -189,23 +189,23 @@ class HtmlWrapperHandler(WrapperHandler):
self.global_type) self.global_type)
def _meta_replacement(self, key, value): def _meta_replacement(self, key, value):
if key == b"timeout": if key == "timeout":
if value == b"long": if value == "long":
return '<meta name="timeout" content="long">' return '<meta name="timeout" content="long">'
if key == b"title": if key == "title":
value = value.decode('utf-8').replace("&", "&amp;").replace("<", "&lt;") value = value.replace("&", "&amp;").replace("<", "&lt;")
return '<title>%s</title>' % value return '<title>%s</title>' % value
return None return None
def _script_replacement(self, key, value): def _script_replacement(self, key, value):
if key == b"script": if key == "script":
attribute = value.decode('utf-8').replace("&", "&amp;").replace('"', "&quot;") attribute = value.replace("&", "&amp;").replace('"', "&quot;")
return '<script src="%s"></script>' % attribute return '<script src="%s"></script>' % attribute
return None return None
class WorkersHandler(HtmlWrapperHandler): class WorkersHandler(HtmlWrapperHandler):
global_type = b"dedicatedworker" global_type = "dedicatedworker"
path_replace = [(".any.worker.html", ".any.js", ".any.worker.js"), path_replace = [(".any.worker.html", ".any.js", ".any.worker.js"),
(".worker.html", ".worker.js")] (".worker.html", ".worker.js")]
wrapper = """<!doctype html> wrapper = """<!doctype html>
...@@ -234,7 +234,7 @@ class WindowHandler(HtmlWrapperHandler): ...@@ -234,7 +234,7 @@ class WindowHandler(HtmlWrapperHandler):
class AnyHtmlHandler(HtmlWrapperHandler): class AnyHtmlHandler(HtmlWrapperHandler):
global_type = b"window" global_type = "window"
path_replace = [(".any.html", ".any.js")] path_replace = [(".any.html", ".any.js")]
wrapper = """<!doctype html> wrapper = """<!doctype html>
<meta charset=utf-8> <meta charset=utf-8>
...@@ -254,7 +254,7 @@ self.GLOBAL = { ...@@ -254,7 +254,7 @@ self.GLOBAL = {
class SharedWorkersHandler(HtmlWrapperHandler): class SharedWorkersHandler(HtmlWrapperHandler):
global_type = b"sharedworker" global_type = "sharedworker"
path_replace = [(".any.sharedworker.html", ".any.js", ".any.worker.js")] path_replace = [(".any.sharedworker.html", ".any.js", ".any.worker.js")]
wrapper = """<!doctype html> wrapper = """<!doctype html>
<meta charset=utf-8> <meta charset=utf-8>
...@@ -269,7 +269,7 @@ fetch_tests_from_worker(new SharedWorker("%(path)s%(query)s")); ...@@ -269,7 +269,7 @@ fetch_tests_from_worker(new SharedWorker("%(path)s%(query)s"));
class ServiceWorkersHandler(HtmlWrapperHandler): class ServiceWorkersHandler(HtmlWrapperHandler):
global_type = b"serviceworker" global_type = "serviceworker"
path_replace = [(".any.serviceworker.html", ".any.js", ".any.worker.js")] path_replace = [(".any.serviceworker.html", ".any.js", ".any.worker.js")]
wrapper = """<!doctype html> wrapper = """<!doctype html>
<meta charset=utf-8> <meta charset=utf-8>
...@@ -307,11 +307,11 @@ done(); ...@@ -307,11 +307,11 @@ done();
return None return None
def _script_replacement(self, key, value): def _script_replacement(self, key, value):
if key == b"script": if key == "script":
attribute = value.decode('utf-8').replace("\\", "\\\\").replace('"', '\\"') attribute = value.replace("\\", "\\\\").replace('"', '\\"')
return 'importScripts("%s")' % attribute return 'importScripts("%s")' % attribute
if key == b"title": if key == "title":
value = value.decode('utf-8').replace("\\", "\\\\").replace('"', '\\"') value = value.replace("\\", "\\\\").replace('"', '\\"')
return 'self.META_TITLE = "%s";' % value return 'self.META_TITLE = "%s";' % value
return None return None
...@@ -922,17 +922,22 @@ def run(**kwargs): ...@@ -922,17 +922,22 @@ def run(**kwargs):
signal.signal(signal.SIGTERM, handle_signal) signal.signal(signal.SIGTERM, handle_signal)
signal.signal(signal.SIGINT, handle_signal) signal.signal(signal.SIGINT, handle_signal)
while (all(item.is_alive() for item in iter_procs(servers)) and while (all(subproc.is_alive() for subproc in iter_procs(servers)) and
not received_signal.is_set()): not received_signal.is_set()):
for item in iter_procs(servers): for subproc in iter_procs(servers):
item.join(1) subproc.join(1)
exited = [item for item in iter_procs(servers) if not item.is_alive()]
subject = "subprocess" if len(exited) == 1 else "subprocesses" failed_subproc = 0
for subproc in iter_procs(servers):
logger.info("%s %s exited:" % (len(exited), subject)) if subproc.is_alive():
logger.info('Status of subprocess "%s": running' % subproc.name)
for item in iter_procs(servers): else:
logger.info("Status of %s:\t%s" % (item.name, "running" if item.is_alive() else "not running")) if subproc.exitcode == 0:
logger.info('Status of subprocess "%s": exited correctly' % subproc.name)
else:
logger.warning('Status of subprocess "%s": failed. Exit with non-zero status: %d' % (subproc.name, subproc.exitcode))
failed_subproc += 1
return failed_subproc
def main(): def main():
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment