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

Unified Diff: PRESUBMIT_test.py

Issue 595213004: Add PRESUBMIT check for #ifdefs on values that are always defined. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: moved to single regex, expanded list of macros, fix error message Created 6 years, 3 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
« PRESUBMIT.py ('K') | « 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 dd67eb1a53258bb58c76dff3613a2b6cc5d138d7..2aed5dfc1b4e074b5efa131b74da0000f4c891fc 100755
--- a/PRESUBMIT_test.py
+++ b/PRESUBMIT_test.py
@@ -413,6 +413,28 @@ class InvalidOSMacroNamesTest(unittest.TestCase):
self.assertEqual(0, len(errors))
+class InvalidIfDefinedMacroNamesTest(unittest.TestCase):
+ def testInvalidIfDefinedMacroNames(self):
+ lines = ['#if defined(TARGET_IPHONE_SIMULATOR)',
+ '#if !defined(TARGET_IPHONE_SIMULATOR)',
+ '#elif defined(TARGET_IPHONE_SIMULATOR)',
+ '#ifdef TARGET_IPHONE_SIMULATOR',
+ ' # ifdef TARGET_IPHONE_SIMULATOR',
+ '# if defined(VALID) || defined(TARGET_IPHONE_SIMULATOR)',
+ '# else // defined(TARGET_IPHONE_SIMULATOR)',
+ '#endif // defined(TARGET_IPHONE_SIMULATOR)',]
+ errors = PRESUBMIT._CheckForInvalidIfDefinedMacrosInFile(
+ MockInputApi(), MockFile('some/path/source.mm', lines))
+ self.assertEqual(len(lines), len(errors))
+
+ def testValidIfDefinedMacroNames(self):
+ lines = ['#if defined(FOO)',
+ '#ifdef BAR',]
+ errors = PRESUBMIT._CheckForInvalidIfDefinedMacrosInFile(
+ MockInputApi(), MockFile('some/path/source.cc', lines))
+ self.assertEqual(0, len(errors))
+
+
class CheckAddedDepsHaveTetsApprovalsTest(unittest.TestCase):
def testFilesToCheckForIncomingDeps(self):
changed_lines = [
« PRESUBMIT.py ('K') | « PRESUBMIT.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698