mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
Update web-platform-tests to revision cd44958a002b1ad494168e0290554644de84526e
This commit is contained in:
parent
2ed23ce4c9
commit
4443426308
103 changed files with 1740 additions and 1138 deletions
|
@ -89,7 +89,11 @@ def run(*args, **kwargs):
|
|||
logger.info(path)
|
||||
|
||||
|
||||
def __main__():
|
||||
def main():
|
||||
kwargs = get_parser().parse_args()
|
||||
|
||||
run(None, vars(kwargs))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
|
@ -11,10 +11,14 @@ select = E,W,F,N
|
|||
# E305: expected 2 blank lines after end of function or class
|
||||
# E402: module level import not at top of file
|
||||
# E731: do not assign a lambda expression, use a def
|
||||
# W504: line break after binary operator
|
||||
# W601: .has_key() is deprecated, use ‘in’
|
||||
# W605: invalid escape sequence
|
||||
# W606: 'async' and 'await' are reserved keywords starting with Python 3.7
|
||||
# N801: class names should use CapWords convention
|
||||
# N802: function name should be lowercase
|
||||
ignore = E128,E129,E226,E231,E251,E265,E302,E303,E305,E402,E731,W601,N801,N802
|
||||
# N806: variable in function should be lowercase
|
||||
ignore = E128,E129,E226,E231,E251,E265,E302,E303,E305,E402,E731,W504,W601,W605,W606,N801,N802,N806
|
||||
exclude =
|
||||
.tox,
|
||||
pywebsocket,
|
||||
|
|
|
@ -11,9 +11,11 @@ select = E,W,F,N
|
|||
# E305: expected 2 blank lines after end of function or class
|
||||
# E402: module level import not at top of file
|
||||
# E731: do not assign a lambda expression, use a def
|
||||
# W504: line break after binary operator
|
||||
# W605: invalid escape sequence
|
||||
# N801: class names should use CapWords convention
|
||||
# N802: function name should be lowercase
|
||||
ignore = E128,E129,E226,E231,E251,E265,E302,E303,E305,E402,E731,N801,N802
|
||||
ignore = E128,E129,E226,E231,E251,E265,E302,E303,E305,E402,E731,W504,W605,N801,N802
|
||||
exclude =
|
||||
.tox,
|
||||
pywebsocket,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
flake8==3.5.0
|
||||
pycodestyle==2.3.1
|
||||
pyflakes==1.6.0
|
||||
pep8-naming==0.4.1
|
||||
flake8==3.6.0
|
||||
pycodestyle==2.4.0
|
||||
pyflakes==2.0.0
|
||||
pep8-naming==0.7.0
|
||||
|
|
|
@ -210,7 +210,7 @@ class FennecBrowser(FirefoxBrowser):
|
|||
process_class=ProcessHandler,
|
||||
process_args={"processOutputLine": [self.on_output]})
|
||||
|
||||
self.logger.debug("Starting Fennec")
|
||||
self.logger.debug("Starting %s" % self.package_name)
|
||||
# connect to a running emulator
|
||||
self.runner.device.connect()
|
||||
|
||||
|
@ -222,7 +222,7 @@ class FennecBrowser(FirefoxBrowser):
|
|||
local="tcp:{}".format(self.marionette_port),
|
||||
remote="tcp:{}".format(self.marionette_port))
|
||||
|
||||
self.logger.debug("Fennec Started")
|
||||
self.logger.debug("%s Started" % self.package_name)
|
||||
|
||||
def stop(self, force=False):
|
||||
if self.runner is not None:
|
||||
|
|
|
@ -15,7 +15,8 @@ __wptrunner__ = {"product": "webkit",
|
|||
"wdspec": "WebKitDriverWdspecExecutor"},
|
||||
"executor_kwargs": "executor_kwargs",
|
||||
"env_extras": "env_extras",
|
||||
"env_options": "env_options"}
|
||||
"env_options": "env_options",
|
||||
"run_info_extras": "run_info_extras"}
|
||||
|
||||
|
||||
def check_args(**kwargs):
|
||||
|
@ -31,22 +32,22 @@ def browser_kwargs(test_type, run_info_data, config, **kwargs):
|
|||
|
||||
|
||||
def capabilities_for_port(server_config, **kwargs):
|
||||
if kwargs["webkit_port"] == "gtk":
|
||||
capabilities = {
|
||||
port_name = kwargs["webkit_port"]
|
||||
if port_name in ["gtk", "wpe"]:
|
||||
port_key_map = {"gtk": "webkitgtk"}
|
||||
browser_options_port = port_key_map.get(port_name, port_name)
|
||||
browser_options_key = "%s:browserOptions" % browser_options_port
|
||||
|
||||
return {
|
||||
"browserName": "MiniBrowser",
|
||||
"browserVersion": "2.20",
|
||||
"platformName": "ANY",
|
||||
"webkitgtk:browserOptions": {
|
||||
browser_options_key: {
|
||||
"binary": kwargs["binary"],
|
||||
"args": kwargs.get("binary_args", []),
|
||||
"certificates": [
|
||||
{"host": server_config["browser_host"],
|
||||
"certificateFile": kwargs["host_cert_path"]}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
return capabilities
|
||||
"certificateFile": kwargs["host_cert_path"]}]}}
|
||||
|
||||
return {}
|
||||
|
||||
|
@ -69,6 +70,10 @@ def env_options():
|
|||
return {}
|
||||
|
||||
|
||||
def run_info_extras(**kwargs):
|
||||
return {"webkit_port": kwargs["webkit_port"]}
|
||||
|
||||
|
||||
class WebKitBrowser(Browser):
|
||||
"""Generic WebKit browser is backed by WebKit's WebDriver implementation,
|
||||
which is supplied through ``wptrunner.webdriver.WebKitDriverServer``.
|
||||
|
|
|
@ -1,8 +1,55 @@
|
|||
import json
|
||||
import re
|
||||
import sys
|
||||
|
||||
from mozlog.structured.formatters.base import BaseFormatter
|
||||
|
||||
|
||||
LONE_SURROGATE_RE = re.compile(u"[\uD800-\uDFFF]")
|
||||
|
||||
|
||||
def surrogate_replacement_ucs4(match):
|
||||
return "U+" + hex(ord(match.group()))[2:]
|
||||
|
||||
|
||||
class SurrogateReplacementUcs2(object):
|
||||
def __init__(self):
|
||||
self.skip = False
|
||||
|
||||
def __call__(self, match):
|
||||
char = match.group()
|
||||
|
||||
if self.skip:
|
||||
self.skip = False
|
||||
return char
|
||||
|
||||
is_low = 0xD800 <= ord(char) <= 0xDBFF
|
||||
|
||||
escape = True
|
||||
if is_low:
|
||||
next_idx = match.end()
|
||||
if next_idx < len(match.string):
|
||||
next_char = match.string[next_idx]
|
||||
if 0xDC00 <= ord(next_char) <= 0xDFFF:
|
||||
escape = False
|
||||
|
||||
if not escape:
|
||||
self.skip = True
|
||||
return char
|
||||
|
||||
return "U+" + hex(ord(match.group()))[2:]
|
||||
|
||||
|
||||
if sys.maxunicode == 0x10FFFF:
|
||||
surrogate_replacement = surrogate_replacement_ucs4
|
||||
else:
|
||||
surrogate_replacement = SurrogateReplacementUcs2()
|
||||
|
||||
|
||||
def replace_lone_surrogate(data):
|
||||
return LONE_SURROGATE_RE.subn(surrogate_replacement, data)[0]
|
||||
|
||||
|
||||
class WptreportFormatter(BaseFormatter):
|
||||
"""Formatter that produces results in the format that wpreport expects."""
|
||||
|
||||
|
@ -40,7 +87,7 @@ class WptreportFormatter(BaseFormatter):
|
|||
|
||||
def create_subtest(self, data):
|
||||
test = self.find_or_create_test(data)
|
||||
subtest_name = data["subtest"]
|
||||
subtest_name = replace_lone_surrogate(data["subtest"])
|
||||
|
||||
subtest = {
|
||||
"name": subtest_name,
|
||||
|
@ -57,7 +104,7 @@ class WptreportFormatter(BaseFormatter):
|
|||
if "expected" in data:
|
||||
subtest["expected"] = data["expected"]
|
||||
if "message" in data:
|
||||
subtest["message"] = data["message"]
|
||||
subtest["message"] = replace_lone_surrogate(data["message"])
|
||||
|
||||
def test_end(self, data):
|
||||
test = self.find_or_create_test(data)
|
||||
|
@ -67,7 +114,7 @@ class WptreportFormatter(BaseFormatter):
|
|||
if "expected" in data:
|
||||
test["expected"] = data["expected"]
|
||||
if "message" in data:
|
||||
test["message"] = data["message"]
|
||||
test["message"] = replace_lone_surrogate(data["message"])
|
||||
|
||||
def assertion_count(self, data):
|
||||
test = self.find_or_create_test(data)
|
||||
|
|
|
@ -4,10 +4,13 @@ import time
|
|||
from os.path import dirname, join
|
||||
from StringIO import StringIO
|
||||
|
||||
import mock
|
||||
|
||||
from mozlog import handlers, structuredlog
|
||||
|
||||
sys.path.insert(0, join(dirname(__file__), "..", ".."))
|
||||
|
||||
from wptrunner import formatters
|
||||
from wptrunner.formatters import WptreportFormatter
|
||||
|
||||
|
||||
|
@ -62,3 +65,73 @@ def test_wptreport_run_info_optional(capfd):
|
|||
output.seek(0)
|
||||
output_obj = json.load(output)
|
||||
assert "run_info" not in output_obj or output_obj["run_info"] == {}
|
||||
|
||||
|
||||
def test_wptreport_lone_surrogate(capfd):
|
||||
output = StringIO()
|
||||
logger = structuredlog.StructuredLogger("test_a")
|
||||
logger.add_handler(handlers.StreamHandler(output, WptreportFormatter()))
|
||||
|
||||
# output a bunch of stuff
|
||||
logger.suite_start(["test-id-1"]) # no run_info arg!
|
||||
logger.test_start("test-id-1")
|
||||
logger.test_status("test-id-1",
|
||||
subtest=u"Name with surrogate\uD800",
|
||||
status="FAIL",
|
||||
message=u"\U0001F601 \uDE0A\uD83D")
|
||||
logger.test_end("test-id-1",
|
||||
status="PASS",
|
||||
message=u"\uDE0A\uD83D \U0001F601")
|
||||
logger.suite_end()
|
||||
|
||||
# check nothing got output to stdout/stderr
|
||||
# (note that mozlog outputs exceptions during handling to stderr!)
|
||||
captured = capfd.readouterr()
|
||||
assert captured.out == ""
|
||||
assert captured.err == ""
|
||||
|
||||
# check the actual output of the formatter
|
||||
output.seek(0)
|
||||
output_obj = json.load(output)
|
||||
test = output_obj["results"][0]
|
||||
assert test["message"] == u"U+de0aU+d83d \U0001F601"
|
||||
subtest = test["subtests"][0]
|
||||
assert subtest["name"] == u"Name with surrogateU+d800"
|
||||
assert subtest["message"] == u"\U0001F601 U+de0aU+d83d"
|
||||
|
||||
|
||||
def test_wptreport_lone_surrogate_ucs2(capfd):
|
||||
# Since UCS4 is a superset of UCS2 we can meaningfully test the UCS2 code on a
|
||||
# UCS4 build, but not the reverse. However UCS2 is harder to handle and UCS4 is
|
||||
# the commonest (and sensible) configuration, so that's OK.
|
||||
output = StringIO()
|
||||
logger = structuredlog.StructuredLogger("test_a")
|
||||
logger.add_handler(handlers.StreamHandler(output, WptreportFormatter()))
|
||||
|
||||
with mock.patch.object(formatters, 'surrogate_replacement', formatters.SurrogateReplacementUcs2()):
|
||||
# output a bunch of stuff
|
||||
logger.suite_start(["test-id-1"]) # no run_info arg!
|
||||
logger.test_start("test-id-1")
|
||||
logger.test_status("test-id-1",
|
||||
subtest=u"Name with surrogate\uD800",
|
||||
status="FAIL",
|
||||
message=u"\U0001F601 \uDE0A\uD83D \uD83D\uDE0A")
|
||||
logger.test_end("test-id-1",
|
||||
status="PASS",
|
||||
message=u"\uDE0A\uD83D \uD83D\uDE0A \U0001F601")
|
||||
logger.suite_end()
|
||||
|
||||
# check nothing got output to stdout/stderr
|
||||
# (note that mozlog outputs exceptions during handling to stderr!)
|
||||
captured = capfd.readouterr()
|
||||
assert captured.out == ""
|
||||
assert captured.err == ""
|
||||
|
||||
# check the actual output of the formatter
|
||||
output.seek(0)
|
||||
output_obj = json.load(output)
|
||||
test = output_obj["results"][0]
|
||||
assert test["message"] == u"U+de0aU+d83d \U0001f60a \U0001F601"
|
||||
subtest = test["subtests"][0]
|
||||
assert subtest["name"] == u"Name with surrogateU+d800"
|
||||
assert subtest["message"] == u"\U0001F601 U+de0aU+d83d \U0001f60a"
|
||||
|
|
|
@ -7,8 +7,6 @@ import traceback
|
|||
from six.moves.urllib.parse import parse_qs, quote, unquote, urljoin
|
||||
from six import iteritems
|
||||
|
||||
from h2.events import RequestReceived, DataReceived
|
||||
|
||||
from .constants import content_types
|
||||
from .pipes import Pipeline, template
|
||||
from .ranges import RangeParser
|
||||
|
@ -79,7 +77,7 @@ class DirectoryHandler(object):
|
|||
%(items)s
|
||||
</ul>
|
||||
""" % {"path": cgi.escape(url_path),
|
||||
"items": "\n".join(self.list_items(url_path, path))} # flake8: noqa
|
||||
"items": "\n".join(self.list_items(url_path, path))} # noqa: E122
|
||||
|
||||
def list_items(self, base_path, path):
|
||||
assert base_path.endswith("/")
|
||||
|
|
|
@ -548,7 +548,7 @@ class Http1WebTestRequestHandler(BaseWebTestRequestHandler):
|
|||
self.close_connection = True
|
||||
return
|
||||
|
||||
except Exception as e:
|
||||
except Exception:
|
||||
err = traceback.format_exc()
|
||||
if response:
|
||||
response.set_error(500, err)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue