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

Roll WPT internal tools to 6a5c1eb4f386da68adc77c84ac3f6e3fa1cb3033

The changes are mostly minor, though there is a change to wptserve to
return success/failure for some methods in ResponseWriter.

Bug: None
Change-Id: I5acd12e630ccaf8288c56a41d6c953921b9b3685
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2339374Reviewed-by: default avatarRobert Ma <robertma@chromium.org>
Commit-Queue: Stephen McGruer <smcgruer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#795010}
parent 18c4f4eb
......@@ -22,7 +22,7 @@ Local Modifications: None
Name: web-platform-tests - Test Suites for Web Platform specifications
Short Name: wpt
URL: https://github.com/web-platform-tests/wpt/
Version: 22901727d52297378d44b217af0b4c06d5b0a484
Version: 6a5c1eb4f386da68adc77c84ac3f6e3fa1cb3033
License: LICENSES FOR W3C TEST SUITES (https://www.w3.org/Consortium/Legal/2008/03-bsd-license.html)
License File: wpt/wpt/LICENSE.md
Security Critical: no
......
......@@ -9,7 +9,7 @@ cd $DIR
TARGET_DIR=$DIR/wpt
REMOTE_REPO="https://github.com/web-platform-tests/wpt.git"
WPT_HEAD=22901727d52297378d44b217af0b4c06d5b0a484
WPT_HEAD=6a5c1eb4f386da68adc77c84ac3f6e3fa1cb3033
function clone {
# Remove existing repo if already exists.
......
......@@ -898,7 +898,9 @@ def create_parser():
help="The WPT directory. Use this "
"option if the lint script exists outside the repository")
parser.add_argument("--ignore-glob", type=ensure_text, action="append",
help="Additional file glob to ignore (repeat to add more)")
help="Additional file glob to ignore (repeat to add more). "
"Globs are matched against paths relative to REPO_ROOT "
"using fnmatch, except that path separators are normalized.")
parser.add_argument("--all", action="store_true", help="If no paths are passed, try to lint the whole "
"working directory, not just files that changed")
return parser
......
......@@ -420,6 +420,11 @@ class WebPlatformTestRegexp(Regexp):
pattern = br"web\-platform\.test"
name = "WEB-PLATFORM.TEST"
description = "Internal web-platform.test domain used"
to_fix = """
use [server-side substitution](https://web-platform-tests.org/writing-tests/server-pipes.html#sub),
along with the [`.sub` filename-flag](https://web-platform-tests.org/writing-tests/file-names.html#test-features),
to replace web-platform.test with `{{domains[]}}`
"""
class Webidl2Regexp(Regexp):
......
......@@ -558,7 +558,7 @@ class Chrome(Browser):
with open(installer_path, "rb") as f:
unzip(f, dest)
os.remove(installer_path)
return self.find_nightly_binary(dest, channel)
return self.find_nightly_binary(dest)
def install_mojojs(self, dest):
url = self._latest_chromium_snapshot_url() + "mojojs.zip"
......@@ -603,10 +603,12 @@ class Chrome(Browser):
self._last_change = get(revision_url).text.strip()
return "https://storage.googleapis.com/chromium-browser-snapshots/%s/%s/" % (architecture, self._last_change)
def find_nightly_binary(self, dest, channel):
binary = "Chromium" if uname[0] == "Darwin" else "chrome"
def find_nightly_binary(self, dest):
if uname[0] == "Darwin":
return find_executable("Chromium",
os.path.join(dest, self._chromium_package_name(), "Chromium.app", "Contents", "MacOS"))
# find_executable will add .exe on Windows automatically.
return find_executable(binary, os.path.join(dest, self._chromium_package_name()))
return find_executable("chrome", os.path.join(dest, self._chromium_package_name()))
def find_binary(self, venv_path=None, channel=None):
if channel == "nightly":
......@@ -680,13 +682,21 @@ class Chrome(Browser):
else self._chromium_chromedriver_url(None)
self.logger.info("Downloading ChromeDriver from %s" % url)
unzip(get(url).raw, dest)
# The two sources of ChromeDriver have different zip structures:
# * Chromium archives the binary inside a chromedriver_* directory;
# * Chrome archives the binary directly.
# We want to make sure the binary always ends up directly in bin/.
chromedriver_dir = os.path.join(
dest, 'chromedriver_%s' % self._chromedriver_platform_string())
unzipped_path = find_executable("chromedriver", chromedriver_dir)
assert unzipped_path is not None
shutil.move(unzipped_path, dest)
rmtree(chromedriver_dir)
return find_executable("chromedriver", dest)
binary_path = find_executable("chromedriver", chromedriver_dir)
if binary_path is not None:
shutil.move(binary_path, dest)
rmtree(chromedriver_dir)
binary_path = find_executable("chromedriver", dest)
assert binary_path is not None
return binary_path
def install_webdriver(self, dest=None, channel=None, browser_binary=None):
if channel == "nightly":
......
......@@ -107,7 +107,7 @@ def rmtree(path):
# hasn't been fully released (a common issue).
def handle_remove_readonly(func, path, exc):
excvalue = exc[1]
if func in (os.rmdir, os.remove) and excvalue.errno == errno.EACCES:
if func in (os.rmdir, os.remove, os.unlink) and excvalue.errno == errno.EACCES:
os.chmod(path, stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO) # 0777
func(path)
else:
......
......@@ -742,7 +742,7 @@ class ResponseWriter(object):
if not self._headers_complete:
self._response.content = data
self.end_headers()
self.write_raw_content(data)
return self.write_raw_content(data)
def write_raw_content(self, data):
"""Writes the data 'as is'"""
......@@ -750,11 +750,9 @@ class ResponseWriter(object):
raise ValueError('data cannot be None')
if isinstance(data, (text_type, binary_type)):
# Deliberately allows both text and binary types. See `self.encode`.
self.write(data)
return self.write(data)
else:
self.write_content_file(data)
if not self._response.explicit_flush:
self.flush()
return self.write_content_file(data)
def write(self, data):
"""Write directly to the response, converting unicode to bytes
......@@ -771,15 +769,19 @@ class ResponseWriter(object):
"""Write a file-like object directly to the response in chunks.
Does not flush."""
self.content_written = True
success = True
while True:
buf = data.read(self.file_chunk_size)
if not buf:
success = False
break
try:
self._wfile.write(buf)
except socket.error:
success = False
break
data.close()
return success
def encode(self, data):
"""Convert unicode to bytes according to response.encoding."""
......
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