diff --git a/presubmit_canned_checks.py b/presubmit_canned_checks.py index 3f7ac0cddf..213ba33051 100644 --- a/presubmit_canned_checks.py +++ b/presubmit_canned_checks.py @@ -2130,11 +2130,15 @@ def CheckInclusiveLanguage(input_api, output_api, ] # Note that this matches exact path prefixes, and does not match - # subdirectories. Only files directly in an exlcluded path will + # subdirectories. Only files directly in an excluded path will # match. def IsExcludedFile(affected_file, excluded_paths): local_dir = input_api.os_path.dirname(affected_file.LocalPath()) + # Excluded paths use forward slashes. + if input_api.platform == 'win32': + local_dir = local_dir.replace('\\', '/') + return local_dir in excluded_paths def CheckForMatch(affected_file, line_num, line, term, message, error): diff --git a/tests/presubmit_canned_checks_test.py b/tests/presubmit_canned_checks_test.py index a03e640a16..cee18da784 100644 --- a/tests/presubmit_canned_checks_test.py +++ b/tests/presubmit_canned_checks_test.py @@ -29,8 +29,8 @@ class InclusiveLanguageCheckTest(unittest.TestCase): MockFile( os.path.normpath( 'infra/inclusive_language_presubmit_exempt_dirs.txt'), [ - os.path.normpath('some/dir') + ' 2 1', - os.path.normpath('some/other/dir') + ' 2 1', + 'some/dir 2 1', + 'some/other/dir 2 1', ]), MockFile( os.path.normpath('some/ios/file.mm'), @@ -133,8 +133,8 @@ class InclusiveLanguageCheckTest(unittest.TestCase): MockFile( os.path.normpath( 'infra/inclusive_language_presubmit_exempt_dirs.txt'), [ - os.path.normpath('some/ios') + ' 2 1', - os.path.normpath('some/other/dir') + ' 2 1', + 'some/ios 2 1', + 'some/other/dir 2 1', ]), MockFile( os.path.normpath('some/ios/file.mm'), @@ -186,8 +186,8 @@ class InclusiveLanguageCheckTest(unittest.TestCase): MockFile( os.path.normpath( 'infra/inclusive_language_presubmit_exempt_dirs.txt'), [ - os.path.normpath('some/dir') + ' 2 1', - os.path.normpath('some/other/dir') + ' 2 1', + 'some/dir 2 1', + 'some/other/dir 2 1', ]), MockFile( os.path.normpath('some/ios/file.mm'), @@ -249,8 +249,8 @@ class InclusiveLanguageCheckTest(unittest.TestCase): MockFile( os.path.normpath( 'infra/inclusive_language_presubmit_exempt_dirs.txt'), [ - os.path.normpath('.') + ' 2 1', - os.path.normpath('some/other/dir') + ' 2 1', + '. 2 1', + 'some/other/dir 2 1', ]), MockFile( os.path.normpath('presubmit_canned_checks_test.py'),