Fix pylint file list matching on Windows

Windows paths use backward slash separator, which
escapes regular expressions for white and black lists
in PRESUBMIT.py filters

See https://goo.gl/6c7aku for discussion

Bug:

Change-Id: Ia1d133c5b6cfa6cb364b1500b7b7abe583bce346
Reviewed-on: https://chromium-review.googlesource.com/461141
Commit-Queue: Marc-Antoine Ruel <maruel@chromium.org>
Reviewed-by: Marc-Antoine Ruel <maruel@chromium.org>
changes/41/461141/4
anatoly techtonik 8 years ago committed by Commit Bot
parent af0fd4eb99
commit bdcdc59cb6

@ -525,7 +525,8 @@ def GetUnitTestsInDirectory(
continue continue
unit_tests.append(input_api.os_path.join(directory, filename)) unit_tests.append(input_api.os_path.join(directory, filename))
to_run += 1 to_run += 1
input_api.logging.debug('Found %d files, running %d' % (found, to_run)) input_api.logging.debug('Found %d files, running %d unit tests'
% (found, to_run))
if not to_run: if not to_run:
return [ return [
output_api.PresubmitPromptWarning( output_api.PresubmitPromptWarning(
@ -675,6 +676,9 @@ def _FetchAllFiles(input_api, white_list, black_list):
# can break another unmodified file. # can break another unmodified file.
# Use code similar to InputApi.FilterSourceFile() # Use code similar to InputApi.FilterSourceFile()
def Find(filepath, filters): def Find(filepath, filters):
if input_api.platform == 'win32':
filepath = filepath.replace('\\', '/')
for item in filters: for item in filters:
if input_api.re.match(item, filepath): if input_api.re.match(item, filepath):
return True return True

@ -2627,7 +2627,7 @@ class CannedChecksUnittest(PresubmitTestsBase):
input_api, input_api,
[presubmit.os.path.join('random_directory', 'b'), '--verbose'], [presubmit.os.path.join('random_directory', 'b'), '--verbose'],
cwd=self.fake_root_dir) cwd=self.fake_root_dir)
input_api.logging.debug('Found 5 files, running 1') input_api.logging.debug('Found 5 files, running 1 unit tests')
self.mox.ReplayAll() self.mox.ReplayAll()
results = presubmit_canned_checks.RunUnitTestsInDirectory( results = presubmit_canned_checks.RunUnitTestsInDirectory(

Loading…
Cancel
Save