Commit d185121d authored by Robert Ma's avatar Robert Ma Committed by Commit Bot

[WPT] Properly ignore DIR_METADATA and OWNERS in lint

`wpt lint --ignore-glob` uses fnmatch to match patterns, which means
1. Patterns must match the full filename (we need a wildcard at the
   beginning).
2. Path separators are not treated specially (i.e. we need to use
   platform-dependent path separators).

Furthermore, we need to ignore OWNERS files, too, which was forgotten in
an earlier change.

Add tests to prevent regressions.

Fixed: 1103374
Change-Id: I62e6ea5ebef900c60b10a325f01683fa5ed836c6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2326110
Commit-Queue: Robert Ma <robertma@chromium.org>
Reviewed-by: default avatarStephen McGruer <smcgruer@chromium.org>
Auto-Submit: Robert Ma <robertma@chromium.org>
Cr-Commit-Position: refs/heads/master@{#792792}
parent 9d8df62a
......@@ -17,9 +17,8 @@ def _LintWPT(input_api, output_api):
information about the lint tool.
"""
wpt_path = input_api.os_path.join(input_api.PresubmitLocalPath(), 'wpt')
linter_path = input_api.os_path.join(
input_api.PresubmitLocalPath(), '..', '..', '..', 'blink', 'tools',
'blinkpy', 'third_party', 'wpt', 'wpt', 'wpt')
linter_path = input_api.os_path.join(input_api.PresubmitLocalPath(), '..', '..', 'tools', 'blinkpy', 'third_party', 'wpt',
'wpt', 'wpt')
paths_in_wpt = []
for abs_path in input_api.AbsoluteLocalPaths():
......@@ -38,7 +37,8 @@ def _LintWPT(input_api, output_api):
'lint',
'--repo-root=%s' % wpt_path,
'--ignore-glob=*-expected.txt',
'--ignore-glob=DIR_METADATA',
'--ignore-glob=*DIR_METADATA',
'--ignore-glob=*OWNERS',
] + paths_in_wpt
proc = input_api.subprocess.Popen(
......
......@@ -4,6 +4,7 @@
# found in the LICENSE file.
import os
import shutil
import subprocess
import sys
import unittest
......@@ -76,9 +77,13 @@ class MockFile(object):
class LintWPTTest(unittest.TestCase):
def setUp(self):
self._test_file = os.path.join(os.path.dirname(__file__), 'wpt', '_DO_NOT_SUBMIT_.html')
self._ignored_directory = os.path.join(os.path.dirname(__file__), 'wpt', 'css', '_DNS_')
def tearDown(self):
os.remove(self._test_file)
if os.path.exists(self._test_file):
os.remove(self._test_file)
if os.path.exists(self._ignored_directory):
shutil.rmtree(self._ignored_directory)
def testWPTLintSuccess(self):
with open(self._test_file, 'w') as f:
......@@ -99,6 +104,19 @@ class LintWPTTest(unittest.TestCase):
errors = PRESUBMIT._LintWPT(mock_input, mock_output)
self.assertEqual(len(errors), 1)
def testWPTLintIgnore(self):
os.mkdir(self._ignored_directory)
files = []
for f in ['DIR_METADATA', 'OWNERS', 'test-expected.txt']:
path = os.path.abspath(os.path.join(self._ignored_directory, f))
files.append(path)
open(path, 'w').close()
mock_input = MockInputApi()
mock_output = MockOutputApi()
mock_input.affected_paths = files
errors = PRESUBMIT._LintWPT(mock_input, mock_output)
self.assertEqual(len(errors), 0)
class DontModifyIDLFilesTest(unittest.TestCase):
def testModifiesIDL(self):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment