Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(256)

Unified Diff: PRESUBMIT_test.py

Issue 12845013: Adding _Check* function for invalid OS_MACROs in src/PRESUBMIT.py (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « PRESUBMIT.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: PRESUBMIT_test.py
diff --git a/PRESUBMIT_test.py b/PRESUBMIT_test.py
index 6a29aca96ed4af7dbb7c506f920e8d6b0b000b7a..8c4b3ffe7baf1c163683c68eae5b3eaef7442092 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()
« no previous file with comments | « PRESUBMIT.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698