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

Unified Diff: PRESUBMIT_test.py

Issue 344563003: Add PRESUBMIT.py warning for contradictory NOTREACHED() use. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 6 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 3bebc678c616978a8494da5cee552004cc2b90a7..baa5f88741d9c2727f2846264dbb95448572cf5f 100755
--- a/PRESUBMIT_test.py
+++ b/PRESUBMIT_test.py
@@ -393,6 +393,44 @@ class InvalidOSMacroNamesTest(unittest.TestCase):
self.assertEqual(0, len(errors))
+class CheckContradictoryNotreachedUseTest(unittest.TestCase):
+ def testValid(self):
+ lines = [r'{',
+ r" char a = '\\', b = '\0', c = '\'';",
+ r' char d[] = "NOTREACHED();";',
+ r' NOTREACHED(); // NOTREACHED();',
+ r' /* NOTREACHED(); */',
+ r' // line continuation \\',
+ r' still inside comment',
+ r' // comment followed by empty line',
+ r'',
+ r'}',
+ r'switch (i) {',
+ r' case 7: NOTREACHED(); break;',
+ r'}']
+ output = PRESUBMIT._CheckContradictoryNotreachedUseInFile(
+ MockInputApi(), MockFile('some/path/foo_platform.cc', lines))
+ self.assertEqual(0, len(output))
+
+ def testInvalid(self):
+ lines = ['{',
+ ' NOTREACHED();',
+ ' return;',
+ '}',
+ '{',
+ ' NOTREACHED();',
+ ' /* */',
+ ' return;',
+ ' /* */',
+ '}',
+ 'switch (i) {',
+ ' case 7: NOTREACHED(); some_thing(); break;',
+ '}']
+ output = PRESUBMIT._CheckContradictoryNotreachedUseInFile(
+ MockInputApi(), MockFile('some/path/foo_platform.cc', lines))
+ self.assertEqual(3, len(output))
+
+
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