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

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: Rebase. 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
« 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 f81b316aa2e025c261369e86d4ed32d106236493..760d70bfbf731884c4ef4a59e8079f656c06a148 100755
--- a/PRESUBMIT_test.py
+++ b/PRESUBMIT_test.py
@@ -413,6 +413,52 @@ class InvalidOSMacroNamesTest(unittest.TestCase):
self.assertEqual(0, len(errors))
+class CheckContradictoryNotreachedUseTest(unittest.TestCase):
+ def testValid(self):
+ lines = ['{',
+ ' // NOTREACHED();',
+ ' /* NOTREACHED(); */',
+ " char a = '\\\\', b = '\\0', c = '\\'';",
+ ' char d[] = "NOTREACHED();";',
+ ' NOTREACHED(); // blah',
+ ' /* comment */',
+ ' // line continuation \\',
+ ' still inside comment',
+ ' // comment followed by empty line',
+ '',
+ ' ;; ; ;;;',
+ '}',
+ 'switch (i) {',
+ ' case 7: NOTREACHED(); break;',
+ '}']
+ output = PRESUBMIT._CheckContradictoryNotreachedUseInFile(
+ MockInputApi(), MockFile('some/path/foo_platform.cc', lines))
+ self.assertEqual(0, len(output))
+
+ def testInvalid(self):
+ lines = ['{',
+ ' NOTREACHED();',
+ ' return;',
+ '}',
+ '{',
+ ' NOTREACHED();',
+ ' /* */',
+ ' return;',
+ ' /* */',
+ '}',
+ '{',
+ ' NOTREACHED();',
+ ' // trailing space, not a line continuation \\ ',
+ ' return;',
+ '}',
+ 'switch (i) {',
+ ' case 7: NOTREACHED(); some_thing(); break;',
+ '}']
+ output = PRESUBMIT._CheckContradictoryNotreachedUseInFile(
+ MockInputApi(), MockFile('some/path/foo_platform.cc', lines))
+ self.assertEqual(4, len(output))
+
+
class CheckAddedDepsHaveTetsApprovalsTest(unittest.TestCase):
def testFilesToCheckForIncomingDeps(self):
changed_lines = [
« 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