Update web-platform-tests to revision e8bfc205e36ad699601212cd50083870bad9a75d

This commit is contained in:
Ms2ger 2016-11-14 11:07:09 +01:00
parent 65dd6d4340
commit ccdb0a3458
1428 changed files with 118036 additions and 9786 deletions

View file

@ -0,0 +1,32 @@
from __future__ import absolute_import
import fnmatch as _stdlib_fnmatch
import os
__all__ = ["fnmatch", "fnmatchcase", "filter", "translate"]
def fnmatch(name, pat):
name = os.path.normcase(name)
pat = os.path.normcase(pat)
return fnmatchcase(name, pat)
def fnmatchcase(name, pat):
if '?' not in pat and '[' not in pat:
wildcards = pat.count("*")
if wildcards == 0:
return name == pat
elif wildcards == 1 and pat[0] == "*":
return name.endswith(pat[1:])
elif wildcards == 1 and pat[-1] == "*":
return name.startswith(pat[:-1])
return _stdlib_fnmatch.fnmatchcase(name, pat)
def filter(names, pat):
return [n for n in names if fnmatch(n, pat)]
translate = _stdlib_fnmatch.translate

View file

@ -3,7 +3,6 @@ from __future__ import print_function, unicode_literals
import abc
import argparse
import ast
import fnmatch
import json
import os
import re
@ -12,6 +11,7 @@ import sys
from collections import defaultdict
from . import fnmatch
from ..localpaths import repo_root
from manifest.sourcefile import SourceFile
@ -65,6 +65,7 @@ def parse_whitelist(f):
parts[-1] = int(parts[-1])
error_type, file_match, line_number = parts
file_match = os.path.normcase(file_match)
if error_type == "*":
ignored_files.add(file_match)
@ -79,10 +80,14 @@ def filter_whitelist_errors(data, path, errors):
Filter out those errors that are whitelisted in `data`.
"""
if not errors:
return []
whitelisted = [False for item in range(len(errors))]
normpath = os.path.normcase(path)
for file_match, whitelist_errors in iteritems(data):
if fnmatch.fnmatch(path, file_match):
if fnmatch.fnmatchcase(path, file_match):
for i, (error_type, msg, path, line) in enumerate(errors):
if error_type in whitelist_errors:
allowed_lines = whitelist_errors[error_type]

View file

@ -0,0 +1,11 @@
from __future__ import unicode_literals
from six import integer_types, text_type
def check_errors(errors):
for e in errors:
error_type, description, path, line_number = e
assert isinstance(error_type, text_type)
assert isinstance(description, text_type)
assert isinstance(path, text_type)
assert line_number is None or isinstance(line_number, integer_types)

View file

@ -1,6 +1,7 @@
from __future__ import unicode_literals
from ..lint import check_file_contents
from .base import check_errors
import os
import pytest
import six
@ -39,6 +40,8 @@ def test_trailing_whitespace():
error_map = check_with_files(b"test; ")
for (filename, (errors, kind)) in error_map.items():
check_errors(errors)
expected = [("TRAILING WHITESPACE", "Whitespace at EOL", filename, 1)]
if kind == "web-strict":
expected.append(("PARSE-FAILED", "Unable to parse file", filename, None))
@ -49,6 +52,8 @@ def test_indent_tabs():
error_map = check_with_files(b"def foo():\n\x09pass")
for (filename, (errors, kind)) in error_map.items():
check_errors(errors)
expected = [("INDENT TABS", "Tabs used for indentation", filename, 2)]
if kind == "web-strict":
expected.append(("PARSE-FAILED", "Unable to parse file", filename, None))
@ -59,6 +64,8 @@ def test_cr_not_at_eol():
error_map = check_with_files(b"line1\rline2\r")
for (filename, (errors, kind)) in error_map.items():
check_errors(errors)
expected = [("CR AT EOL", "CR character in line separator", filename, 1)]
if kind == "web-strict":
expected.append(("PARSE-FAILED", "Unable to parse file", filename, None))
@ -69,6 +76,8 @@ def test_cr_at_eol():
error_map = check_with_files(b"line1\r\nline2\r\n")
for (filename, (errors, kind)) in error_map.items():
check_errors(errors)
expected = [
("CR AT EOL", "CR character in line separator", filename, 1),
("CR AT EOL", "CR character in line separator", filename, 2),
@ -82,6 +91,8 @@ def test_w3c_test_org():
error_map = check_with_files(b"import('http://www.w3c-test.org/')")
for (filename, (errors, kind)) in error_map.items():
check_errors(errors)
expected = [("W3C-TEST.ORG", "External w3c-test.org domain used", filename, 1)]
if kind == "python":
expected.append(("PARSE-FAILED", "Unable to parse file", filename, 1))
@ -94,6 +105,8 @@ def test_webidl2_js():
error_map = check_with_files(b"<script src=/resources/webidl2.js>")
for (filename, (errors, kind)) in error_map.items():
check_errors(errors)
expected = [("WEBIDL2.JS", "Legacy webidl2.js script used", filename, 1)]
if kind == "python":
expected.append(("PARSE-FAILED", "Unable to parse file", filename, 1))
@ -106,6 +119,8 @@ def test_console():
error_map = check_with_files(b"<script>\nconsole.log('error');\nconsole.error ('log')\n</script>")
for (filename, (errors, kind)) in error_map.items():
check_errors(errors)
if kind in ["web-lax", "web-strict", "js"]:
assert errors == [
("CONSOLE", "Console logging API used", filename, 2),
@ -126,6 +141,8 @@ def test_meta_timeout():
error_map = check_with_files(code)
for (filename, (errors, kind)) in error_map.items():
check_errors(errors)
if kind in ["web-lax", "web-strict"]:
assert errors == [
("MULTIPLE-TIMEOUT", "More than one meta name='timeout'", filename, None),
@ -148,6 +165,8 @@ def test_early_testharnessreport():
error_map = check_with_files(code)
for (filename, (errors, kind)) in error_map.items():
check_errors(errors)
if kind in ["web-lax", "web-strict"]:
assert errors == [
("EARLY-TESTHARNESSREPORT", "testharnessreport.js script seen before testharness.js script", filename, None),
@ -168,6 +187,8 @@ def test_multiple_testharness():
error_map = check_with_files(code)
for (filename, (errors, kind)) in error_map.items():
check_errors(errors)
if kind in ["web-lax", "web-strict"]:
assert errors == [
("MULTIPLE-TESTHARNESS", "More than one <script src='/resources/testharness.js'>", filename, None),
@ -190,6 +211,8 @@ def test_multiple_testharnessreport():
error_map = check_with_files(code)
for (filename, (errors, kind)) in error_map.items():
check_errors(errors)
if kind in ["web-lax", "web-strict"]:
assert errors == [
("MULTIPLE-TESTHARNESSREPORT", "More than one <script src='/resources/testharnessreport.js'>", filename, None),
@ -211,6 +234,8 @@ def test_present_testharnesscss():
error_map = check_with_files(code)
for (filename, (errors, kind)) in error_map.items():
check_errors(errors)
if kind in ["web-lax", "web-strict"]:
assert errors == [
("PRESENT-TESTHARNESSCSS", "Explicit link to testharness.css present", filename, None),
@ -233,6 +258,8 @@ def test_testharness_path():
error_map = check_with_files(code)
for (filename, (errors, kind)) in error_map.items():
check_errors(errors)
expected = [("W3C-TEST.ORG", "External w3c-test.org domain used", filename, 5)]
if kind == "python":
expected.append(("PARSE-FAILED", "Unable to parse file", filename, 1))
@ -258,6 +285,8 @@ def test_testharnessreport_path():
error_map = check_with_files(code)
for (filename, (errors, kind)) in error_map.items():
check_errors(errors)
expected = [("W3C-TEST.ORG", "External w3c-test.org domain used", filename, 5)]
if kind == "python":
expected.append(("PARSE-FAILED", "Unable to parse file", filename, 1))
@ -282,6 +311,8 @@ def test_not_testharness_path():
error_map = check_with_files(code)
for (filename, (errors, kind)) in error_map.items():
check_errors(errors)
if kind == "python":
assert errors == [
("PARSE-FAILED", "Unable to parse file", filename, 1),
@ -295,6 +326,8 @@ def test_print_statement():
error_map = check_with_files(b"def foo():\n print 'statement'\n print\n")
for (filename, (errors, kind)) in error_map.items():
check_errors(errors)
if kind == "python":
assert errors == [
("PRINT STATEMENT", "Print function used", filename, 2),
@ -312,6 +345,8 @@ def test_print_function():
error_map = check_with_files(b"def foo():\n print('function')\n")
for (filename, (errors, kind)) in error_map.items():
check_errors(errors)
if kind == "python":
assert errors == [
("PRINT STATEMENT", "Print function used", filename, 2),
@ -346,6 +381,7 @@ def test_open_mode():
for method in ["open", "file"]:
code = open_mode_code.format(method).encode("utf-8")
errors = check_file_contents("", "test.py", six.BytesIO(code))
check_errors(errors)
message = ("File opened without providing an explicit mode (note: " +
"binary files must be read with 'b' in the mode flags)")

View file

@ -59,7 +59,8 @@ CONSOLE:streams/resources/test-utils.js: 12
'CR AT EOL': {None},
},
}
expected_ignored = {"*.pdf", "resources/*"}
expected_data = {os.path.normcase(p): e for p, e in expected_data.items()}
expected_ignored = {os.path.normcase(x) for x in {"*.pdf", "resources/*"}}
data, ignored = parse_whitelist(input_buffer)
assert data == expected_data
assert ignored == expected_ignored

View file

@ -1,6 +1,7 @@
from __future__ import unicode_literals
from ..lint import check_path
from .base import check_errors
import pytest
import six
@ -11,6 +12,7 @@ def test_allowed_path_length():
filename = basename + idx * "a"
errors = check_path("/foo/", filename)
check_errors(errors)
assert errors == []
@ -22,4 +24,5 @@ def test_forbidden_path_length():
message = "/%s longer than maximum path length (%s > 150)" % (filename, 146 + idx)
errors = check_path("/foo/", filename)
assert errors == [("PATH LENGTH", message, None)]
check_errors(errors)
assert errors == [("PATH LENGTH", message, filename, None)]