Bug 1291735 - Lint all files under the wpt root, not just committed ones, r=Ms2ger
authorJames Graham <james@hoppipolla.co.uk>
Tue, 02 Aug 2016 22:28:41 +0100
changeset 351475 fe7e2efb803f645c50bca64ddb89cd0129f0b4b4
parent 351474 c9b70a1998fcba46f84850089d29152eff7d9c6f
child 351476 f9825328b6b3c0ab9e924d425c2179d43811f6a0
push id1324
push usermtabara@mozilla.com
push dateMon, 16 Jan 2017 13:07:44 +0000
treeherdermozilla-release@a01c49833940 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMs2ger
bugs1291735
milestone51.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1291735 - Lint all files under the wpt root, not just committed ones, r=Ms2ger This removes the git dependency MozReview-Commit-ID: 7qqNJUOopFi
testing/web-platform/tests/tools/lint/lint.py
--- a/testing/web-platform/tests/tools/lint/lint.py
+++ b/testing/web-platform/tests/tools/lint/lint.py
@@ -34,16 +34,25 @@ you could add the following line to the 
 %s:%s"""
 
 def all_git_paths(repo_root):
     command_line = ["git", "ls-tree", "-r", "--name-only", "HEAD"]
     output = subprocess.check_output(command_line, cwd=repo_root)
     for item in output.split("\n"):
         yield item
 
+def all_filesystem_paths(repo_root):
+    for dirpath, dirnames, filenames in os.walk(repo_root):
+        for filename in filenames:
+            yield os.path.relpath(os.path.join(dirpath, filename), repo_root)
+
+def all_paths(repo_root, ignore_local):
+    fn = all_git_paths if ignore_local else all_filesystem_paths
+    for item in fn(repo_root):
+        yield item
 
 def check_path_length(repo_root, path):
     if len(path) + 1 > 150:
         return [("PATH LENGTH", "/%s longer than maximum path length (%d > 150)" % (path, len(path) + 1), None)]
     return []
 
 def set_type(error_type, errors):
     return [(error_type,) + error for error in errors]
@@ -300,22 +309,24 @@ def output_error_count(error_count):
         print("There were %d errors (%s)" % (count, by_type))
 
 def parse_args():
     parser = argparse.ArgumentParser()
     parser.add_argument("paths", nargs="*",
                         help="List of paths to lint")
     parser.add_argument("--json", action="store_true",
                         help="Output machine-readable JSON format")
+    parser.add_argument("--ignore-local", action="store_true",
+                        help="Ignore locally added files in the working directory (requires git).")
     return parser.parse_args()
 
 def main():
     repo_root = localpaths.repo_root
     args = parse_args()
-    paths = args.paths if args.paths else all_git_paths(repo_root)
+    paths = args.paths if args.paths else all_paths(repo_root, args.ignore_local)
     return lint(repo_root, paths, args.json)
 
 def lint(repo_root, paths, output_json):
     error_count = defaultdict(int)
     last = None
 
     whitelist = parse_whitelist_file(os.path.join(repo_root, "lint.whitelist"))