Bug 1288432 - Use new mozlint configuration for wpt and wpt_manifest linters, r?jgraham draft
authorAndrew Halberstadt <ahalberstadt@mozilla.com>
Fri, 02 Jun 2017 09:48:07 -0400
changeset 588435 a518dafb94767020e8f670f7b4e71cbf22af1cc7
parent 588434 c7443a152ffa8f6837ed55553e633f123c78a3cc
child 588436 a238eb1a281c0b5df3cb732cd4d10fd0cd1c2385
push id62032
push userahalberstadt@mozilla.com
push dateFri, 02 Jun 2017 19:52:29 +0000
reviewersjgraham
bugs1288432
milestone55.0a1
Bug 1288432 - Use new mozlint configuration for wpt and wpt_manifest linters, r?jgraham MozReview-Commit-ID: FQeOf5MBoSF
tools/lint/wpt.lint.py
tools/lint/wpt.yml
tools/lint/wpt/__init__.py
tools/lint/wpt/wpt.py
tools/lint/wpt/wpt_manifest.py
tools/lint/wpt_manifest.lint.py
tools/lint/wpt_manifest.yml
new file mode 100644
--- /dev/null
+++ b/tools/lint/wpt.yml
@@ -0,0 +1,7 @@
+wpt:
+    description: web-platform-tests lint
+    include:
+        - testing/web-platform/tests
+    exclude: []
+    type: external
+    payload: wpt.wpt:lint
new file mode 100644
rename from tools/lint/wpt.lint.py
rename to tools/lint/wpt/wpt.py
--- a/tools/lint/wpt.lint.py
+++ b/tools/lint/wpt/wpt.py
@@ -6,50 +6,33 @@
 
 import json
 import os
 
 from mozprocess import ProcessHandler
 
 from mozlint import result
 
-top_src_dir = os.path.join(os.path.dirname(__file__), os.pardir, os.pardir)
-tests_dir = os.path.join(top_src_dir, "testing", "web-platform", "tests")
-
 results = []
 
 
-def process_line(line):
-    try:
-        data = json.loads(line)
-    except ValueError:
-        return
-    data["level"] = "error"
-    data["path"] = os.path.relpath(os.path.join(tests_dir, data["path"]), top_src_dir)
-    results.append(result.from_linter(LINTER, **data))
+def lint(files, config, **kwargs):
+    tests_dir = os.path.join(kwargs['root'], 'testing', 'web-platform', 'tests')
 
+    def process_line(line):
+        try:
+            data = json.loads(line)
+        except ValueError:
+            return
+        data["level"] = "error"
+        data["path"] = os.path.relpath(os.path.join(tests_dir, data["path"]), kwargs['root'])
+        results.append(result.from_config(config, **data))
 
-def run_process():
     path = os.path.join(tests_dir, "lint")
     proc = ProcessHandler([path, "--json"], env=os.environ,
                           processOutputLine=process_line)
     proc.run()
     try:
         proc.wait()
     except KeyboardInterrupt:
         proc.kill()
 
-
-def lint(files, **kwargs):
-    run_process()
     return results
-
-
-LINTER = {
-    'name': "wpt",
-    'description': "web-platform-tests lint",
-    'include': [
-        'testing/web-platform/tests',
-    ],
-    'exclude': [],
-    'type': 'external',
-    'payload': lint,
-}
rename from tools/lint/wpt_manifest.lint.py
rename to tools/lint/wpt/wpt_manifest.py
--- a/tools/lint/wpt_manifest.lint.py
+++ b/tools/lint/wpt/wpt_manifest.py
@@ -3,26 +3,13 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 import imp
 import os
 
 
-def lint(files, logger, **kwargs):
+def lint(files, config, logger, **kwargs):
     wpt_dir = os.path.join(kwargs["root"], "testing", "web-platform")
     manifestupdate = imp.load_source("manifestupdate",
                                      os.path.join(wpt_dir, "manifestupdate.py"))
     manifestupdate.update(logger, wpt_dir, True)
-
-
-LINTER = {
-    'name': "wpt_manifest",
-    'description': "web-platform-tests manifest lint",
-    'include': [
-        'testing/web-platform/tests',
-        'testing/web-platform/mozilla/tests',
-    ],
-    'exclude': [],
-    'type': 'structured_log',
-    'payload': lint,
-}
new file mode 100644
--- /dev/null
+++ b/tools/lint/wpt_manifest.yml
@@ -0,0 +1,8 @@
+wpt_manifest:
+    description: web-platform-tests manifest lint
+    include:
+        - testing/web-platform/tests
+        - testing/web-platform/mozilla/tests
+    exclude: []
+    type: structured_log
+    payload: wpt.wpt_manifest:lint