mirror of
https://github.com/servo/servo.git
synced 2025-07-31 11:10:22 +01:00
Auto merge of #14166 - Wafflespeanut:tidy, r=frewsxcv
Allow tidy to run custom project-specific lints <!-- Please describe your changes on the following line: --> Since tidy is a package, it shouldn't contain our WPT lint. This PR changes the file list generator (we already have) into an object, and allows tidy to run custom python lint scripts (specified in the config file) under the context of `LintRunner`. The errors are then chained into our mechanism. r? @frewsxcv (cc @jdm @edunham @aneeshusa and anyone else interested in reviewing it) --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors <!-- Either: --> - [x] There are tests for these changes <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/14166) <!-- Reviewable:end -->
This commit is contained in:
commit
290a1696dc
10 changed files with 189 additions and 66 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)
|
Loading…
Add table
Add a link
Reference in a new issue