Skip to content

Commit

Permalink
Roll in new version of WPT tools
Browse files Browse the repository at this point in the history
This roll is mainly to include
web-platform-tests/wpt#10323, which fixes a bug
that `wpt manifest` would fail when the local manifest is invalid.

wpt.config.json is changed to accomodate:
web-platform-tests/wpt#9998
web-platform-tests/wpt#10078

Bug: 822041
Change-Id: I074afd90e32db299fc6f58b870f9b72576fab225
Reviewed-on: https://chromium-review.googlesource.com/997764
Reviewed-by: Quinten Yearsley <qyearsley@chromium.org>
Commit-Queue: Robert Ma <robertma@chromium.org>
Cr-Commit-Position: refs/heads/master@{#548584}
  • Loading branch information
Hexcles authored and Commit Bot committed Apr 5, 2018
1 parent adc57df commit 31f5e5a
Show file tree
Hide file tree
Showing 14 changed files with 306 additions and 131 deletions.
Expand Up @@ -51,7 +51,7 @@ Local Modifications: None
Name: web-platform-tests - Test Suites for Web Platform specifications
Short Name: wpt
URL: https://github.com/w3c/web-platform-tests/
Version: 5122353fba91c9d97599cb94a02fb8ec7ec1384e
Version: d00f7bab7aecadbc2fc9a47172d090b4ba7e2ef2
License: LICENSES FOR W3C TEST SUITES (http://www.w3.org/Consortium/Legal/2008/04-testsuite-copyright.html)
License File: wpt/wpt/LICENSE.md
Security Critical: no
Expand Down
Expand Up @@ -9,7 +9,7 @@ cd $DIR

TARGET_DIR=$DIR/wpt
REMOTE_REPO="https://chromium.googlesource.com/external/w3c/web-platform-tests.git"
WPT_HEAD=5122353fba91c9d97599cb94a02fb8ec7ec1384e
WPT_HEAD=d00f7bab7aecadbc2fc9a47172d090b4ba7e2ef2

function clone {
# Remove existing repo if already exists.
Expand Down
@@ -1,9 +1,8 @@
{
"bind_hostname": false,
"doc_root": null,
"ws_doc_root": null,
"external_host": null,
"check_subdomains": false,
"server_host": "127.0.0.1",
"ports": {
"http": [8001, 8081],
"https": [8444],
Expand Down
@@ -1,18 +1,31 @@
*#
# Python
*.py[co]
.virtualenv/
_venv/
.cache/
.pytest_cache/
.tox/

# Node
node_modules/

# WPT repo stuff
/MANIFEST.json

testharness_runner.html
!/testharness_runner.html
!/tools/wptrunner/wptrunner/testharness_runner.html

_certs
config.json

# Various OS/editor specific files
*#
*.sw[po]
*~
MANIFEST.json
\#*
_certs
.virtualenv
config.json
node_modules
scratch
testharness_runner.html
webdriver/.idea
.idea/
.vscode/
.DS_Store
*.rej
_venv
webdriver/.cache
@@ -1,14 +1,14 @@
{"host": "web-platform.test",
{"browser_host": "web-platform.test",
"doc_root": null,
"ws_doc_root": null,
"external_host": null,
"server_host": null,
"ports":{"http":[8000, "auto"],
"https":[8443],
"ws":["auto"],
"wss":["auto"]},
"check_subdomains": true,
"log_level":"debug",
"bind_hostname": true,
"bind_address": true,
"ssl": {"type": "pregenerated",
"encrypt_after_connect": false,
"openssl": {
Expand Down
Expand Up @@ -17,6 +17,12 @@ def fnmatch_translate(pat, path_name=False):
else:
any_char = "."
parts.append("^(?:.*/)?")
if pat[-1] == "/":
# If the last character is / match this directory or any subdirectory
pat = pat[:-1]
suffix = "(?:/|$)"
else:
suffix = "$"
while i < len(pat):
c = pat[i]
if c == "\\":
Expand Down Expand Up @@ -63,7 +69,7 @@ def fnmatch_translate(pat, path_name=False):

if seq:
raise ValueError
parts.append("$")
parts.append(suffix)
try:
return re.compile("".join(parts))
except Exception:
Expand All @@ -84,7 +90,7 @@ def parse_line(line):
if dir_only:
line = line[:-1]

return invert, dir_only, fnmatch_translate(line, "/" in line)
return invert, dir_only, fnmatch_translate(line, dir_only)


class PathFilter(object):
Expand Down
Expand Up @@ -9,6 +9,7 @@
import re
import subprocess
import sys
import tempfile

from collections import defaultdict

Expand Down Expand Up @@ -58,17 +59,20 @@ def setup_logging(prefix=False):
%s: %s"""

def all_filesystem_paths(repo_root):
path_filter = PathFilter(repo_root, extras=[".git/*"])
for dirpath, dirnames, filenames in os.walk(repo_root):
def all_filesystem_paths(repo_root, subdir=None):
path_filter = PathFilter(repo_root, extras=[".git/"])
if subdir:
expanded_path = subdir
else:
expanded_path = repo_root
for dirpath, dirnames, filenames in os.walk(expanded_path):
for filename in filenames:
path = os.path.relpath(os.path.join(dirpath, filename), repo_root)
if path_filter(path):
yield path
dirnames[:] = [item for item in dirnames if
path_filter(os.path.relpath(os.path.join(dirpath, item) + "/",
repo_root))]

repo_root)+"/")]

def _all_files_equal(paths):
"""
Expand Down Expand Up @@ -134,6 +138,28 @@ def check_ahem_copy(repo_root, path):
return []


def check_git_ignore(repo_root, paths):
errors = []
with tempfile.TemporaryFile('w+') as f:
f.write('\n'.join(paths))
f.seek(0)
try:
matches = subprocess.check_output(
["git", "check-ignore", "--verbose", "--no-index", "--stdin"], stdin=f)
for match in matches.strip().split('\n'):
match_filter, path = match.split()
_, _, filter_string = match_filter.split(':')
# If the matching filter reported by check-ignore is a special-case exception,
# that's fine. Otherwise, it requires a new special-case exception.
if filter_string[0] != '!':
errors += [("IGNORED PATH", "%s matches an ignore filter in .gitignore - "
"please add a .gitignore exception" % path, path, None)]
except subprocess.CalledProcessError as e:
# Nonzero return code means that no match exists.
pass
return errors


drafts_csswg_re = re.compile(r"https?\:\/\/drafts\.csswg\.org\/([^/?#]+)")
w3c_tr_re = re.compile(r"https?\:\/\/www\.w3c?\.org\/TR\/([^/?#]+)")
w3c_dev_re = re.compile(r"https?\:\/\/dev\.w3c?\.org\/[^/?#]+\/([^/?#]+)")
Expand Down Expand Up @@ -278,7 +304,9 @@ def filter_whitelist_errors(data, errors):

for i, (error_type, msg, path, line) in enumerate(errors):
normpath = os.path.normcase(path)
if error_type in data:
# Allow whitelisting all lint errors except the IGNORED PATH lint,
# which explains how to fix it correctly and shouldn't be ignored.
if error_type in data and error_type != "IGNORED PATH":
wl_files = data[error_type]
for file_match, allowed_lines in iteritems(wl_files):
if None in allowed_lines or line in allowed_lines:
Expand Down Expand Up @@ -722,14 +750,20 @@ def changed_files(wpt_root):

def lint_paths(kwargs, wpt_root):
if kwargs.get("paths"):
r = os.path.realpath(wpt_root)
paths = [os.path.relpath(os.path.realpath(x), r) for x in kwargs["paths"]]
paths = []
for path in kwargs.get("paths"):
if os.path.isdir(path):
path_dir = list(all_filesystem_paths(wpt_root, path))
paths.extend(path_dir)
elif os.path.isfile(path):
paths.append(os.path.relpath(os.path.abspath(path), wpt_root))


elif kwargs["all"]:
paths = list(all_filesystem_paths(wpt_root))
else:
changed_paths = changed_files(wpt_root)
force_all = False
# If we changed the lint itself ensure that we retest everything
for path in changed_paths:
path = path.replace(os.path.sep, "/")
if path == "lint.whitelist" or path.startswith("tools/lint/"):
Expand Down Expand Up @@ -846,6 +880,13 @@ def process_errors(errors):
all_paths_lints = [check_css_globally_unique]
file_lints = [check_regexp_line, check_parsed, check_python_ast, check_script_metadata]

# Don't break users of the lint that don't have git installed.
try:
subprocess.check_output(["git", "--version"])
all_paths_lints += [check_git_ignore]
except subprocess.CalledProcessError:
print('No git present; skipping .gitignore lint.')

if __name__ == "__main__":
args = create_parser().parse_args()
error_count = main(**vars(args))
Expand Down
Expand Up @@ -225,6 +225,9 @@ def load(tests_root, manifest):
rv = Manifest.from_json(tests_root, json.load(f))
except IOError:
return None
except ValueError:
logger.warning("%r may be corrupted", manifest)
return None
return rv

return Manifest.from_json(tests_root, json.load(manifest))
Expand Down

0 comments on commit 31f5e5a

Please sign in to comment.