mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Update web-platform-tests to revision 8a2ceb5f18911302b7a5c1cd2791f4ab50ad4326
This commit is contained in:
parent
462c272380
commit
1f531f66ea
5377 changed files with 174916 additions and 84369 deletions
|
@ -15,8 +15,9 @@ from collections import defaultdict
|
|||
from . import fnmatch
|
||||
from .. import localpaths
|
||||
from ..gitignore.gitignore import PathFilter
|
||||
from ..wpt import testfiles
|
||||
|
||||
from manifest.sourcefile import SourceFile, js_meta_re, python_meta_re
|
||||
from manifest.sourcefile import SourceFile, js_meta_re, python_meta_re, space_chars
|
||||
from six import binary_type, iteritems, itervalues
|
||||
from six.moves import range
|
||||
from six.moves.urllib.parse import urlsplit, urljoin
|
||||
|
@ -126,6 +127,13 @@ def check_worker_collision(repo_root, path, css_mode):
|
|||
return []
|
||||
|
||||
|
||||
def check_ahem_copy(repo_root, path, css_mode):
|
||||
lpath = path.lower()
|
||||
if "ahem" in lpath and lpath.endswith(".ttf"):
|
||||
return [("AHEM COPY", "Don't add extra copies of Ahem, use /fonts/Ahem.ttf", path, None)]
|
||||
return []
|
||||
|
||||
|
||||
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\/[^/?#]+\/([^/?#]+)")
|
||||
|
@ -335,12 +343,24 @@ class ConsoleRegexp(Regexp):
|
|||
file_extensions = [".html", ".htm", ".js", ".xht", ".xhtml", ".svg"]
|
||||
description = "Console logging API used"
|
||||
|
||||
class GenerateTestsRegexp(Regexp):
|
||||
pattern = b"generate_tests\s*\("
|
||||
error = "GENERATE_TESTS"
|
||||
file_extensions = [".html", ".htm", ".js", ".xht", ".xhtml", ".svg"]
|
||||
description = "generate_tests used"
|
||||
|
||||
class PrintRegexp(Regexp):
|
||||
pattern = b"print(?:\s|\s*\()"
|
||||
error = "PRINT STATEMENT"
|
||||
file_extensions = [".py"]
|
||||
description = "Print function used"
|
||||
|
||||
class LayoutTestsRegexp(Regexp):
|
||||
pattern = b"eventSender|testRunner|window\.internals"
|
||||
error = "LAYOUTTESTS APIS"
|
||||
file_extensions = [".html", ".htm", ".js", ".xht", ".xhtml", ".svg"]
|
||||
description = "eventSender/testRunner/window.internals used; these are LayoutTests-specific APIs (WebKit/Blink)"
|
||||
|
||||
regexps = [item() for item in
|
||||
[TrailingWhitespaceRegexp,
|
||||
TabsRegexp,
|
||||
|
@ -349,7 +369,9 @@ regexps = [item() for item in
|
|||
W3CTestOrgRegexp,
|
||||
Webidl2Regexp,
|
||||
ConsoleRegexp,
|
||||
PrintRegexp]]
|
||||
GenerateTestsRegexp,
|
||||
PrintRegexp,
|
||||
LayoutTestsRegexp]]
|
||||
|
||||
def check_regexp_line(repo_root, path, f, css_mode):
|
||||
errors = []
|
||||
|
@ -395,7 +417,7 @@ def check_parsed(repo_root, path, f, css_mode):
|
|||
return [("CONTENT-VISUAL", "Visual test whose filename doesn't end in '-visual'", path, None)]
|
||||
|
||||
for reftest_node in source_file.reftest_nodes:
|
||||
href = reftest_node.attrib.get("href", "")
|
||||
href = reftest_node.attrib.get("href", "").strip(space_chars)
|
||||
parts = urlsplit(href)
|
||||
if parts.scheme or parts.netloc:
|
||||
errors.append(("ABSOLUTE-URL-REF",
|
||||
|
@ -636,6 +658,7 @@ def output_errors_text(errors):
|
|||
pos_string += ":%s" % line_number
|
||||
logger.error("%s: %s (%s)" % (pos_string, description, error_type))
|
||||
|
||||
|
||||
def output_errors_markdown(errors):
|
||||
if not errors:
|
||||
return
|
||||
|
@ -651,6 +674,7 @@ def output_errors_markdown(errors):
|
|||
pos_string += ":%s" % line_number
|
||||
logger.error("%s | %s | %s |" % (error_type, pos_string, description))
|
||||
|
||||
|
||||
def output_errors_json(errors):
|
||||
for error_type, error, path, line_number in errors:
|
||||
print(json.dumps({"path": path, "lineno": line_number,
|
||||
|
@ -669,7 +693,34 @@ def output_error_count(error_count):
|
|||
else:
|
||||
logger.info("There were %d errors (%s)" % (count, by_type))
|
||||
|
||||
def parse_args():
|
||||
|
||||
def changed_files(wpt_root):
|
||||
revish = testfiles.get_revish(revish=None)
|
||||
changed, _ = testfiles.files_changed(revish, set(), include_uncommitted=True, include_new=True)
|
||||
return [os.path.relpath(item, wpt_root) for item in changed]
|
||||
|
||||
|
||||
def lint_paths(kwargs, wpt_root):
|
||||
if kwargs.get("paths"):
|
||||
paths = kwargs["paths"]
|
||||
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/"):
|
||||
force_all = True
|
||||
break
|
||||
paths = (list(changed_paths) if not force_all
|
||||
else list(all_filesystem_paths(wpt_root)))
|
||||
|
||||
return paths
|
||||
|
||||
|
||||
def create_parser():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("paths", nargs="*",
|
||||
help="List of paths to lint")
|
||||
|
@ -681,7 +732,9 @@ def parse_args():
|
|||
help="Run CSS testsuite specific lints")
|
||||
parser.add_argument("--repo-root", help="The WPT directory. Use this"
|
||||
"option if the lint script exists outside the repository")
|
||||
return parser.parse_args()
|
||||
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
|
||||
|
||||
|
||||
def main(**kwargs):
|
||||
|
@ -695,9 +748,11 @@ def main(**kwargs):
|
|||
(False, False): "normal"}[(kwargs.get("json", False),
|
||||
kwargs.get("markdown", False))]
|
||||
|
||||
paths = list(kwargs.get("paths") if kwargs.get("paths") else all_filesystem_paths(repo_root))
|
||||
if output_format == "markdown":
|
||||
setup_logging(True)
|
||||
|
||||
paths = lint_paths(kwargs, repo_root)
|
||||
|
||||
return lint(repo_root, paths, output_format, kwargs.get("css_mode", False))
|
||||
|
||||
|
||||
|
@ -760,12 +815,12 @@ def lint(repo_root, paths, output_format, css_mode):
|
|||
logger.info(line)
|
||||
return sum(itervalues(error_count))
|
||||
|
||||
path_lints = [check_path_length, check_worker_collision]
|
||||
path_lints = [check_path_length, check_worker_collision, check_ahem_copy]
|
||||
all_paths_lints = [check_css_globally_unique]
|
||||
file_lints = [check_regexp_line, check_parsed, check_python_ast, check_script_metadata]
|
||||
|
||||
if __name__ == "__main__":
|
||||
args = parse_args()
|
||||
args = create_parser().parse_args()
|
||||
error_count = main(**vars(args))
|
||||
if error_count > 0:
|
||||
sys.exit(1)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue