mirror of
https://github.com/servo/servo.git
synced 2025-07-29 10:10:34 +01:00
add a --faster option to ./mach test-tidy
which will - only check files changed since the last merge by bors - and skip the wpt-lint
This commit is contained in:
parent
b8e7cd71d6
commit
a9b8d47d5d
2 changed files with 32 additions and 9 deletions
|
@ -256,8 +256,10 @@ class MachCommands(CommandBase):
|
||||||
@Command('test-tidy',
|
@Command('test-tidy',
|
||||||
description='Run the source code tidiness check',
|
description='Run the source code tidiness check',
|
||||||
category='testing')
|
category='testing')
|
||||||
def test_tidy(self):
|
@CommandArgument('--faster', default=False, action="store_true",
|
||||||
return tidy.scan()
|
help="Only check changed files and skip the WPT lint")
|
||||||
|
def test_tidy(self, faster):
|
||||||
|
return tidy.scan(faster)
|
||||||
|
|
||||||
@Command('test-wpt-failure',
|
@Command('test-wpt-failure',
|
||||||
description='Run the web platform tests',
|
description='Run the web platform tests',
|
||||||
|
|
|
@ -13,6 +13,7 @@ import fnmatch
|
||||||
import itertools
|
import itertools
|
||||||
import re
|
import re
|
||||||
import StringIO
|
import StringIO
|
||||||
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
from licenseck import licenses
|
from licenseck import licenses
|
||||||
|
|
||||||
|
@ -554,7 +555,6 @@ def check_reftest_html_files_in_basic_list(reftest_dir):
|
||||||
|
|
||||||
|
|
||||||
def check_wpt_lint_errors():
|
def check_wpt_lint_errors():
|
||||||
import subprocess
|
|
||||||
wpt_working_dir = os.path.abspath(os.path.join(".", "tests", "wpt", "web-platform-tests"))
|
wpt_working_dir = os.path.abspath(os.path.join(".", "tests", "wpt", "web-platform-tests"))
|
||||||
lint_cmd = os.path.join(wpt_working_dir, "lint")
|
lint_cmd = os.path.join(wpt_working_dir, "lint")
|
||||||
try:
|
try:
|
||||||
|
@ -563,20 +563,41 @@ def check_wpt_lint_errors():
|
||||||
yield ("WPT Lint Tool", "", "lint error(s) in Web Platform Tests: exit status {0}".format(e.returncode))
|
yield ("WPT Lint Tool", "", "lint error(s) in Web Platform Tests: exit status {0}".format(e.returncode))
|
||||||
|
|
||||||
|
|
||||||
def scan():
|
def get_file_list(directory, only_changed_files=False):
|
||||||
all_files = (os.path.join(r, f) for r, _, files in os.walk(".") for f in files)
|
if only_changed_files:
|
||||||
files_to_check = filter(should_check, all_files)
|
# only check the files that have been changed since the last merge
|
||||||
|
args = ["git", "log", "-n1", "--author=bors-servo", "--format=%H"]
|
||||||
|
last_merge = subprocess.check_output(args).strip()
|
||||||
|
args = ["git", "diff", "--name-only", last_merge, directory]
|
||||||
|
file_list = subprocess.check_output(args)
|
||||||
|
# also check untracked files
|
||||||
|
args = ["git", "ls-files", "--others", "--exclude-standard", directory]
|
||||||
|
file_list += subprocess.check_output(args)
|
||||||
|
return (os.path.join(".", f) for f in file_list.splitlines())
|
||||||
|
else:
|
||||||
|
return (os.path.join(r, f) for r, _, files in os.walk(directory) for f in files)
|
||||||
|
|
||||||
|
|
||||||
|
def scan(faster=False):
|
||||||
|
# standard checks
|
||||||
|
files_to_check = filter(should_check, get_file_list(".", faster))
|
||||||
checking_functions = (check_flake8, check_lock, check_webidl_spec)
|
checking_functions = (check_flake8, check_lock, check_webidl_spec)
|
||||||
line_checking_functions = (check_license, check_by_line, check_toml, check_rust, check_spec)
|
line_checking_functions = (check_license, check_by_line, check_toml, check_rust, check_spec)
|
||||||
errors = collect_errors_for_files(files_to_check, checking_functions, line_checking_functions)
|
errors = collect_errors_for_files(files_to_check, checking_functions, line_checking_functions)
|
||||||
|
|
||||||
reftest_files = (os.path.join(r, f) for r, _, files in os.walk(reftest_dir) for f in files)
|
# reftest checks
|
||||||
reftest_to_check = filter(should_check_reftest, reftest_files)
|
reftest_to_check = filter(should_check_reftest, get_file_list(reftest_dir, faster))
|
||||||
r_errors = check_reftest_order(reftest_to_check)
|
r_errors = check_reftest_order(reftest_to_check)
|
||||||
not_found_in_basic_list_errors = check_reftest_html_files_in_basic_list(reftest_dir)
|
not_found_in_basic_list_errors = check_reftest_html_files_in_basic_list(reftest_dir)
|
||||||
wpt_lint_errors = check_wpt_lint_errors()
|
|
||||||
|
|
||||||
|
# wpt lint checks
|
||||||
|
if faster:
|
||||||
|
print "\033[93mUsing test-tidy \033[01m--faster\033[22m, skipping WPT lint\033[0m"
|
||||||
|
wpt_lint_errors = iter([])
|
||||||
|
else:
|
||||||
|
wpt_lint_errors = check_wpt_lint_errors()
|
||||||
|
|
||||||
|
# collect errors
|
||||||
errors = itertools.chain(errors, r_errors, not_found_in_basic_list_errors, wpt_lint_errors)
|
errors = itertools.chain(errors, r_errors, not_found_in_basic_list_errors, wpt_lint_errors)
|
||||||
|
|
||||||
error = None
|
error = None
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue