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

Side by Side Diff: PRESUBMIT_test.py

Issue 357693004: Revert of 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 unified diff | Download patch
« no previous file with comments | « PRESUBMIT.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 import glob 6 import glob
7 import json 7 import json
8 import os 8 import os
9 import re 9 import re
10 import subprocess 10 import subprocess
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 self.assertTrue(':1 OS_WINDOWS' in errors[0]) 406 self.assertTrue(':1 OS_WINDOWS' in errors[0])
407 self.assertTrue('(did you mean OS_WIN?)' in errors[0]) 407 self.assertTrue('(did you mean OS_WIN?)' in errors[0])
408 408
409 def testValidOSMacroNames(self): 409 def testValidOSMacroNames(self):
410 lines = ['#if defined(%s)' % m for m in PRESUBMIT._VALID_OS_MACROS] 410 lines = ['#if defined(%s)' % m for m in PRESUBMIT._VALID_OS_MACROS]
411 errors = PRESUBMIT._CheckForInvalidOSMacrosInFile( 411 errors = PRESUBMIT._CheckForInvalidOSMacrosInFile(
412 MockInputApi(), MockFile('some/path/foo_platform.cc', lines)) 412 MockInputApi(), MockFile('some/path/foo_platform.cc', lines))
413 self.assertEqual(0, len(errors)) 413 self.assertEqual(0, len(errors))
414 414
415 415
416 class CheckContradictoryNotreachedUseTest(unittest.TestCase):
417 def testValid(self):
418 lines = ['{',
419 ' // NOTREACHED();',
420 ' /* NOTREACHED(); */',
421 " char a = '\\\\', b = '\\0', c = '\\'';",
422 ' char d[] = "NOTREACHED();";',
423 ' NOTREACHED(); // blah',
424 ' /* comment */',
425 ' // line continuation \\',
426 ' still inside comment',
427 ' // comment followed by empty line',
428 '',
429 ' ;; ; ;;;',
430 '}',
431 'switch (i) {',
432 ' case 7: NOTREACHED(); break;',
433 '}']
434 output = PRESUBMIT._CheckContradictoryNotreachedUseInFile(
435 MockInputApi(), MockFile('some/path/foo_platform.cc', lines))
436 self.assertEqual(0, len(output))
437
438 def testInvalid(self):
439 lines = ['{',
440 ' NOTREACHED();',
441 ' return;',
442 '}',
443 '{',
444 ' NOTREACHED();',
445 ' /* */',
446 ' return;',
447 ' /* */',
448 '}',
449 '{',
450 ' NOTREACHED();',
451 ' // trailing space, not a line continuation \\ ',
452 ' return;',
453 '}',
454 'switch (i) {',
455 ' case 7: NOTREACHED(); some_thing(); break;',
456 '}']
457 output = PRESUBMIT._CheckContradictoryNotreachedUseInFile(
458 MockInputApi(), MockFile('some/path/foo_platform.cc', lines))
459 self.assertEqual(4, len(output))
460
461
462 class CheckAddedDepsHaveTetsApprovalsTest(unittest.TestCase): 416 class CheckAddedDepsHaveTetsApprovalsTest(unittest.TestCase):
463 def testFilesToCheckForIncomingDeps(self): 417 def testFilesToCheckForIncomingDeps(self):
464 changed_lines = [ 418 changed_lines = [
465 '"+breakpad",', 419 '"+breakpad",',
466 '"+chrome/installer",', 420 '"+chrome/installer",',
467 '"+chrome/plugin/chrome_content_plugin_client.h",', 421 '"+chrome/plugin/chrome_content_plugin_client.h",',
468 '"+chrome/utility/chrome_content_utility_client.h",', 422 '"+chrome/utility/chrome_content_utility_client.h",',
469 '"+chromeos/chromeos_paths.h",', 423 '"+chromeos/chromeos_paths.h",',
470 '"+components/breakpad",', 424 '"+components/breakpad",',
471 '"+components/nacl/common",', 425 '"+components/nacl/common",',
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
689 for (filename, contents, _) in test_data] 643 for (filename, contents, _) in test_data]
690 644
691 for (filename, _, expected_error) in test_data: 645 for (filename, _, expected_error) in test_data:
692 actual_error = PRESUBMIT._GetIDLParseError(input_api, filename) 646 actual_error = PRESUBMIT._GetIDLParseError(input_api, filename)
693 self.assertTrue(expected_error in str(actual_error), 647 self.assertTrue(expected_error in str(actual_error),
694 "'%s' not found in '%s'" % (expected_error, actual_error)) 648 "'%s' not found in '%s'" % (expected_error, actual_error))
695 649
696 650
697 if __name__ == '__main__': 651 if __name__ == '__main__':
698 unittest.main() 652 unittest.main()
OLDNEW
« 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