Update web-platform-tests to revision d04a8fc02b85bd32799691759c8c05ead07cd939

This commit is contained in:
WPT Sync Bot 2018-03-23 21:12:55 -04:00
parent e8fdc677f4
commit 2b35c55ac7
63 changed files with 2068 additions and 340 deletions

View file

@ -3,7 +3,6 @@
.coverage.*
htmlcov/
coverage.xml
.tox/
.cache/
.hypothesis/
*.py[co]

View file

@ -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 == "\\":
@ -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:
@ -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):

View file

@ -11,7 +11,8 @@ match_data = [
("/*.c", False, ["a.c", ".c"]),
("**/b", False, ["a/b", "a/c/b"]),
("*b", True, ["ab"]),
("**/b", True, ["a/b"])
("**/b", True, ["a/b"]),
("a/", True, ["a", "a/b", "a/b/c"])
]
mismatch_data = [
@ -23,6 +24,7 @@ mismatch_data = [
("**b", True, ["a/b"]),
("a[/]b", True, ["a/b"]),
("**/b", True, ["a/c/b"]),
("a", True, ["ab"])
]
invalid_data = [
@ -40,21 +42,25 @@ filter_data = [
("c/b", True)
]
def expand_data(compact_data):
for pattern, path_name, inputs in compact_data:
for input in inputs:
yield pattern, input, path_name
@pytest.mark.parametrize("pattern, input, path_name", expand_data(match_data))
def tests_match(pattern, input, path_name):
regexp = fnmatch_translate(pattern, path_name)
assert regexp.match(input) is not None
@pytest.mark.parametrize("pattern, input, path_name", expand_data(mismatch_data))
def tests_no_match(pattern, input, path_name):
regexp = fnmatch_translate(pattern, path_name)
assert regexp.match(input) is None
@pytest.mark.parametrize("pattern", invalid_data)
def tests_invalid(pattern):
with pytest.raises(ValueError):
@ -62,6 +68,7 @@ def tests_invalid(pattern):
with pytest.raises(ValueError):
fnmatch_translate(pattern, True)
@pytest.mark.parametrize("path, expected", filter_data)
def test_path_filter(path, expected):
extras = [

View file

@ -60,7 +60,7 @@ you could add the following line to the lint.whitelist file.
%s: %s"""
def all_filesystem_paths(repo_root, subdir=None):
path_filter = PathFilter(repo_root, extras=[".git/*"])
path_filter = PathFilter(repo_root, extras=[".git/"])
if subdir:
expanded_path = subdir
else:
@ -72,8 +72,7 @@ def all_filesystem_paths(repo_root, subdir=None):
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):
"""