diff options
author | dbeam@chromium.org <dbeam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-26 16:21:54 +0000 |
---|---|---|
committer | dbeam@chromium.org <dbeam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-26 16:21:54 +0000 |
commit | b00342e7fa4b2b3ec9c6181d588fb34694a44404 (patch) | |
tree | f3f884f2218b1bd03750f8caa1998f26296c2efc /PRESUBMIT_test.py | |
parent | ab343b45f8f516be187e44a0cb4e478c53e65029 (diff) | |
download | chromium_src-b00342e7fa4b2b3ec9c6181d588fb34694a44404.zip chromium_src-b00342e7fa4b2b3ec9c6181d588fb34694a44404.tar.gz chromium_src-b00342e7fa4b2b3ec9c6181d588fb34694a44404.tar.bz2 |
Adding _Check* function for invalid OS_MACROs in src/PRESUBMIT.py
R=maruel@chromium.org
BUG=none
CONTEXT=http://goo.gl/hrlj1
TEST=PRESUBMIT_test.py and less OS_MAXOSX!
NOTRY=true
Review URL: https://chromiumcodereview.appspot.com/12845013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@190693 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'PRESUBMIT_test.py')
-rwxr-xr-x | PRESUBMIT_test.py | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/PRESUBMIT_test.py b/PRESUBMIT_test.py index 6a29aca..8c4b3ff 100755 --- a/PRESUBMIT_test.py +++ b/PRESUBMIT_test.py @@ -295,7 +295,7 @@ class IncludeOrderTest(unittest.TestCase): self.assertEqual(0, len(warnings)) -class VersionControlerConflictsTest(unittest.TestCase): +class VersionControlConflictsTest(unittest.TestCase): def testTypicalConflict(self): lines = ['<<<<<<< HEAD', ' base::ScopedTempDir temp_dir_;', @@ -356,5 +356,25 @@ class BadExtensionsTest(unittest.TestCase): self.assertEqual(0, len(results)) +class InvalidOSMacroNamesTest(unittest.TestCase): + def testInvalidOSMacroNames(self): + lines = ['#if defined(OS_WINDOWS)', + ' #elif defined(OS_WINDOW)', + ' # if defined(OS_MACOSX) || defined(OS_CHROME)', + '# else // defined(OS_MAC)', + '#endif // defined(OS_MACOS)'] + errors = PRESUBMIT._CheckForInvalidOSMacrosInFile( + MockInputApi(), MockFile('some/path/foo_platform.cc', lines)) + self.assertEqual(len(lines), len(errors)) + self.assertTrue(':1 OS_WINDOWS' in errors[0]) + self.assertTrue('(did you mean OS_WIN?)' in errors[0]) + + def testValidOSMacroNames(self): + lines = ['#if defined(%s)' % m for m in PRESUBMIT._VALID_OS_MACROS] + errors = PRESUBMIT._CheckForInvalidOSMacrosInFile( + MockInputApi(), MockFile('some/path/foo_platform.cc', lines)) + self.assertEqual(0, len(errors)) + + if __name__ == '__main__': unittest.main() |