Auto merge of #9966 - mrobinson:tidy-pyc, r=jdm

Do not run WPT tidy on pyc files

Generalize the mechanism for skipping file patterns and use it for
generating the list of WPT files to lint. Add *.pyc to the list of
file patterns to skip.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9966)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2016-03-11 12:16:03 +05:30
commit 8eb4fb801b

View file

@ -8,18 +8,29 @@
# except according to those terms. # except according to those terms.
import contextlib import contextlib
import os import fnmatch
import itertools import itertools
import json
import os
import re import re
import StringIO
import site import site
import StringIO
import subprocess import subprocess
import sys import sys
import json
from licenseck import licenses from licenseck import licenses
filetypes_to_check = [".rs", ".rc", ".cpp", ".c", ".h", ".lock", ".py", ".toml", ".webidl", ".json"] # File patterns to include in the non-WPT tidy check.
file_patterns_to_check = ["*.rs", "*.rc", "*.cpp", "*.c",
"*.h", "Cargo.lock", "*.py",
"*.toml", "*.webidl", "*.json"]
# File patterns that are ignored for all tidy and lint checks.
file_patterns_to_ignore = [
"*.#*",
"*.pyc",
]
# Files that are ignored for all tidy and lint checks.
ignored_files = [ ignored_files = [
# Generated and upstream code combined with our own. Could use cleanup # Generated and upstream code combined with our own. Could use cleanup
os.path.join(".", "ports", "gonk", "src", "native_window_glue.cpp"), os.path.join(".", "ports", "gonk", "src", "native_window_glue.cpp"),
@ -31,6 +42,7 @@ ignored_files = [
os.path.join(".", "."), os.path.join(".", "."),
] ]
# Directories that are ignored for the non-WPT tidy check.
ignored_dirs = [ ignored_dirs = [
# Upstream # Upstream
os.path.join(".", "support", "android", "apk"), os.path.join(".", "support", "android", "apk"),
@ -64,22 +76,27 @@ def progress_wrapper(iterator):
yield thing yield thing
def filter_file(file_name):
if any(file_name.startswith(ignored_file) for ignored_file in ignored_files):
return False
base_name = os.path.basename(file_name)
if any(fnmatch.fnmatch(base_name, pattern) for pattern in file_patterns_to_ignore):
return False
return True
def filter_files(start_dir, faster, progress): def filter_files(start_dir, faster, progress):
file_iter = get_file_list(start_dir, faster, ignored_dirs) file_iter = get_file_list(start_dir, faster, ignored_dirs)
if progress: if progress:
file_iter = progress_wrapper(file_iter) file_iter = progress_wrapper(file_iter)
for file_name in file_iter: for file_name in file_iter:
if os.path.basename(file_name) == "Cargo.lock": base_name = os.path.basename(file_name)
yield file_name if not any(fnmatch.fnmatch(base_name, pattern) for pattern in file_patterns_to_check):
if ".#" in file_name:
continue continue
if os.path.splitext(file_name)[1] not in filetypes_to_check: if not filter_file(file_name):
continue
if any(file_name.startswith(ignored_file) for ignored_file in ignored_files):
continue continue
yield file_name yield file_name
EMACS_HEADER = "/* -*- Mode:" EMACS_HEADER = "/* -*- Mode:"
VIM_HEADER = "/* vim:" VIM_HEADER = "/* vim:"
MAX_LICENSE_LINESPAN = max(len(license.splitlines()) for license in licenses) MAX_LICENSE_LINESPAN = max(len(license.splitlines()) for license in licenses)
@ -552,7 +569,8 @@ def get_wpt_files(only_changed_files, progress):
if progress: if progress:
file_iter = progress_wrapper(file_iter) file_iter = progress_wrapper(file_iter)
for f in file_iter: for f in file_iter:
yield f[len(wpt_dir):] if filter_file(f):
yield f[len(wpt_dir):]
def check_wpt_lint_errors(files): def check_wpt_lint_errors(files):