mirror of
https://github.com/servo/servo.git
synced 2025-08-02 12:10:29 +01:00
Isolate the WPT lint and make use of the LintRunner
This commit is contained in:
parent
b5cff9db8f
commit
8385c9ae79
3 changed files with 44 additions and 27 deletions
37
python/servo/lints/wpt_lint.py
Normal file
37
python/servo/lints/wpt_lint.py
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
# Copyright 2013 The Servo Project Developers. See the COPYRIGHT
|
||||||
|
# file at the top-level directory of this distribution.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||||
|
# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||||
|
# option. This file may not be copied, modified, or distributed
|
||||||
|
# except according to those terms.
|
||||||
|
|
||||||
|
import os
|
||||||
|
import site
|
||||||
|
|
||||||
|
from servo_tidy.tidy import LintRunner, filter_file
|
||||||
|
|
||||||
|
WPT_PATH = os.path.join(".", "tests", "wpt")
|
||||||
|
SUITES = ["web-platform-tests", os.path.join("mozilla", "tests")]
|
||||||
|
|
||||||
|
|
||||||
|
class Lint(LintRunner):
|
||||||
|
def _get_wpt_files(self, suite):
|
||||||
|
working_dir = os.path.join(WPT_PATH, suite, '')
|
||||||
|
file_iter = self.get_files(working_dir, exclude_dirs=[])
|
||||||
|
print '\nRunning the WPT lint on %s...' % working_dir
|
||||||
|
for f in file_iter:
|
||||||
|
if filter_file(f):
|
||||||
|
yield f[len(working_dir):]
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
wpt_working_dir = os.path.abspath(os.path.join(WPT_PATH, "web-platform-tests"))
|
||||||
|
for suite in SUITES:
|
||||||
|
files = self._get_wpt_files(suite)
|
||||||
|
site.addsitedir(wpt_working_dir)
|
||||||
|
from tools.lint import lint
|
||||||
|
file_dir = os.path.abspath(os.path.join(WPT_PATH, suite))
|
||||||
|
returncode = lint.lint(file_dir, files, output_json=False)
|
||||||
|
if returncode:
|
||||||
|
yield ("WPT Lint Tool", "", "lint error(s) in Web Platform Tests: exit status %s" % returncode)
|
|
@ -14,7 +14,6 @@ import itertools
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import site
|
|
||||||
import StringIO
|
import StringIO
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
@ -30,6 +29,7 @@ config = {
|
||||||
"skip-check-length": False,
|
"skip-check-length": False,
|
||||||
"skip-check-licenses": False,
|
"skip-check-licenses": False,
|
||||||
"check-ordered-json-keys": [],
|
"check-ordered-json-keys": [],
|
||||||
|
"lint-scripts": [],
|
||||||
"ignore": {
|
"ignore": {
|
||||||
"files": [
|
"files": [
|
||||||
"./.", # ignore hidden files
|
"./.", # ignore hidden files
|
||||||
|
@ -870,26 +870,6 @@ def collect_errors_for_files(files_to_check, checking_functions, line_checking_f
|
||||||
yield (filename,) + error
|
yield (filename,) + error
|
||||||
|
|
||||||
|
|
||||||
def get_wpt_files(suite, only_changed_files, progress):
|
|
||||||
wpt_dir = os.path.join(".", "tests", "wpt", suite, "")
|
|
||||||
file_iter = FileList(os.path.join(wpt_dir), only_changed_files=only_changed_files, progress=progress)
|
|
||||||
print '\nRunning the WPT lint...'
|
|
||||||
for f in file_iter:
|
|
||||||
if filter_file(f):
|
|
||||||
yield f[len(wpt_dir):]
|
|
||||||
|
|
||||||
|
|
||||||
def check_wpt_lint_errors(suite, files):
|
|
||||||
wpt_working_dir = os.path.abspath(os.path.join(".", "tests", "wpt", "web-platform-tests"))
|
|
||||||
if os.path.isdir(wpt_working_dir):
|
|
||||||
site.addsitedir(wpt_working_dir)
|
|
||||||
from tools.lint import lint
|
|
||||||
file_dir = os.path.abspath(os.path.join(".", "tests", "wpt", suite))
|
|
||||||
returncode = lint.lint(file_dir, files, output_json=False)
|
|
||||||
if returncode:
|
|
||||||
yield ("WPT Lint Tool", "", "lint error(s) in Web Platform Tests: exit status {0}".format(returncode))
|
|
||||||
|
|
||||||
|
|
||||||
def get_dep_toml_files(only_changed_files=False):
|
def get_dep_toml_files(only_changed_files=False):
|
||||||
if not only_changed_files:
|
if not only_changed_files:
|
||||||
print '\nRunning the dependency licensing lint...'
|
print '\nRunning the dependency licensing lint...'
|
||||||
|
@ -973,13 +953,10 @@ def scan(only_changed_files=False, progress=True):
|
||||||
file_errors = collect_errors_for_files(files_to_check, checking_functions, line_checking_functions)
|
file_errors = collect_errors_for_files(files_to_check, checking_functions, line_checking_functions)
|
||||||
# check dependecy licenses
|
# check dependecy licenses
|
||||||
dep_license_errors = check_dep_license_errors(get_dep_toml_files(only_changed_files), progress)
|
dep_license_errors = check_dep_license_errors(get_dep_toml_files(only_changed_files), progress)
|
||||||
# wpt lint checks
|
# other lint checks
|
||||||
wpt_lint_errors = [
|
lint_errors = run_lint_scripts(only_changed_files, progress)
|
||||||
check_wpt_lint_errors(suite, get_wpt_files(suite, only_changed_files, progress))
|
|
||||||
for suite in ["web-platform-tests", os.path.join("mozilla", "tests")]
|
|
||||||
]
|
|
||||||
# chain all the iterators
|
# chain all the iterators
|
||||||
errors = itertools.chain(config_errors, directory_errors, file_errors, dep_license_errors, *wpt_lint_errors)
|
errors = itertools.chain(config_errors, directory_errors, file_errors, dep_license_errors, lint_errors)
|
||||||
|
|
||||||
error = None
|
error = None
|
||||||
for error in errors:
|
for error in errors:
|
||||||
|
|
|
@ -5,6 +5,9 @@ check-ordered-json-keys = [
|
||||||
"./resources/prefs.json",
|
"./resources/prefs.json",
|
||||||
"./resources/package-prefs.json",
|
"./resources/package-prefs.json",
|
||||||
]
|
]
|
||||||
|
lint-scripts = [
|
||||||
|
"./python/servo/lints/wpt_lint.py",
|
||||||
|
]
|
||||||
|
|
||||||
[ignore]
|
[ignore]
|
||||||
# Ignored packages with duplicated versions
|
# Ignored packages with duplicated versions
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue