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

Side by Side Diff: PRESUBMIT_test.py

Issue 653883002: Adding Presubmit error when OVERRIDE and FINAL is not used as C++11 standard (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: incorporated review comments Created 6 years, 2 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 InvalidOverideAndFinalTest(unittest.TestCase):
417 def testValidOverrideConstructs(self):
418 mock_input_api = MockInputApi()
419 lines = ['foo1() override;',
420 'foo2() final;',
421 '#DEFINE OVERRIDE_METHOD_OVERLOAD',
422 '#DEFINE FINAL_METHOD',
423 '#DEFINE OVERRIDE_OVERRIDE_SOMETHING',
424 '#DEFINE SOMETHING_OVERRIDE_SOMETHING',
425 '#DEFINE SOMETHING_SOMETHING_OVERRIDE',
426 '#DEFINE FINAL_OVERRIDE_FINAL',
427 '#DEFINE SOMETHING_OVERRIDE_FINAL',
428 '#DEFINE OVERRIDE_OVERRIDE_OVERRIDE',
429 '#endif // FINAL_METHOD',
430 '#endif // OVERRIDE_METHOD_OVERLOAD']
431 mock_file_h = MockFile('something.h', lines)
432 mock_input_api.files = [mock_file_h]
433 errors = PRESUBMIT._CheckForOverrideAndFinalRules(mock_input_api,
434 MockOutputApi())
435 self.assertEqual(0, len(errors))
436
437 def testInvalidOverrideConstructsInHeaders(self):
438 mock_input_api = MockInputApi()
439 lines_h = ['foo1() OVERRIDE;']
440 lines_cpp = ['foo2() FINAL;']
M-A Ruel 2014/10/15 15:22:19 Please fix spacing everywhere to be consistent. Yo
MRV 2014/10/15 17:06:12 SOn 2014/10/15 15:22:19, M-A Ruel wrote:
441 mock_file_cpp= MockFile('something.cpp', lines_cpp)
442 mock_file_h = MockFile('something.h', lines_h)
443 mock_input_api.files = [mock_file_h, mock_file_cpp]
444 errors = PRESUBMIT._CheckForOverrideAndFinalRules(mock_input_api,
445 MockOutputApi())
446 self.assertEqual(1, len(errors))
447
448 def testInvalidOverrideConstructsInCpp(self):
449 mock_input_api = MockInputApi()
450 lines_cpp = ['foo2() FINAL;']
451 mock_file_cpp= MockFile('something.cpp', lines_cpp)
452 mock_input_api.files = [mock_file_cpp]
453 errors = PRESUBMIT._CheckForOverrideAndFinalRules(mock_input_api,
454 MockOutputApi())
455 self.assertEqual(1, len(errors))
456
457 def testInvalidOverrideConstructsInCc(self):
458 mock_input_api = MockInputApi()
459 lines_cc = ['foo3() override FINAL;']
460 mock_file_cc = MockFile('something.cc', lines_cc)
461 mock_input_api.files = [mock_file_cc]
462 errors = PRESUBMIT._CheckForOverrideAndFinalRules(mock_input_api,
463 MockOutputApi())
464 self.assertEqual(1, len(errors))
465
466 def testInvalidOverrideConstructsInMm(self):
467 mock_input_api = MockInputApi()
468 lines_mm = ['foo4() OVERRIDE final;']
469 mock_file_mm = MockFile('something.mm', lines_mm)
470 mock_input_api.files = [mock_file_mm]
471 errors = PRESUBMIT._CheckForOverrideAndFinalRules(mock_input_api,
472 MockOutputApi())
473 self.assertEqual(1, len(errors))
474
475
416 class InvalidIfDefinedMacroNamesTest(unittest.TestCase): 476 class InvalidIfDefinedMacroNamesTest(unittest.TestCase):
417 def testInvalidIfDefinedMacroNames(self): 477 def testInvalidIfDefinedMacroNames(self):
418 lines = ['#if defined(TARGET_IPHONE_SIMULATOR)', 478 lines = ['#if defined(TARGET_IPHONE_SIMULATOR)',
419 '#if !defined(TARGET_IPHONE_SIMULATOR)', 479 '#if !defined(TARGET_IPHONE_SIMULATOR)',
420 '#elif defined(TARGET_IPHONE_SIMULATOR)', 480 '#elif defined(TARGET_IPHONE_SIMULATOR)',
421 '#ifdef TARGET_IPHONE_SIMULATOR', 481 '#ifdef TARGET_IPHONE_SIMULATOR',
422 ' # ifdef TARGET_IPHONE_SIMULATOR', 482 ' # ifdef TARGET_IPHONE_SIMULATOR',
423 '# if defined(VALID) || defined(TARGET_IPHONE_SIMULATOR)', 483 '# if defined(VALID) || defined(TARGET_IPHONE_SIMULATOR)',
424 '# else // defined(TARGET_IPHONE_SIMULATOR)', 484 '# else // defined(TARGET_IPHONE_SIMULATOR)',
425 '#endif // defined(TARGET_IPHONE_SIMULATOR)',] 485 '#endif // defined(TARGET_IPHONE_SIMULATOR)',]
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
778 } 838 }
779 for master, bots in bots.iteritems(): 839 for master, bots in bots.iteritems():
780 for bot in bots: 840 for bot in bots:
781 self.assertEqual(master, PRESUBMIT.GetTryServerMasterForBot(bot), 841 self.assertEqual(master, PRESUBMIT.GetTryServerMasterForBot(bot),
782 'bot=%s: expected %s, computed %s' % ( 842 'bot=%s: expected %s, computed %s' % (
783 bot, master, PRESUBMIT.GetTryServerMasterForBot(bot))) 843 bot, master, PRESUBMIT.GetTryServerMasterForBot(bot)))
784 844
785 845
786 if __name__ == '__main__': 846 if __name__ == '__main__':
787 unittest.main() 847 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