OLD | NEW |
---|---|
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 Loading... | |
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', | |
Mike West
2014/10/15 13:10:03
Nit: For completeness, please add test cases for "
MRV
2014/10/15 13:34:46
Done.
| |
423 '#endif // FINAL_METHOD', | |
424 '#endif // OVERRIDE_METHOD_OVERLOAD'] | |
425 mock_file_h = MockFile('something.h', lines) | |
426 mock_input_api.files = [mock_file_h] | |
427 errors = PRESUBMIT._CheckForOverrideAndFinalRules(mock_input_api, | |
428 MockOutputApi()) | |
429 self.assertEqual(0, len(errors)) | |
430 | |
431 def testInvalidOverrideConstructsInHeaders(self): | |
432 mock_input_api = MockInputApi() | |
433 lines = ['foo1() OVERRIDE;'] | |
434 mock_file_h = MockFile('something.h', lines) | |
435 mock_input_api.files = [mock_file_h] | |
436 errors = PRESUBMIT._CheckForOverrideAndFinalRules(mock_input_api, | |
437 MockOutputApi()) | |
438 self.assertEqual(1, len(errors)) | |
439 | |
440 def testInvalidOverrideConstructsInCpp(self): | |
441 mock_input_api = MockInputApi() | |
442 lines = ['foo2() FINAL;'] | |
443 mock_file_cpp= MockFile('something.cpp', lines) | |
444 mock_input_api.files = [mock_file_cpp] | |
445 errors = PRESUBMIT._CheckForOverrideAndFinalRules(mock_input_api, | |
446 MockOutputApi()) | |
447 self.assertEqual(1, len(errors)) | |
448 | |
449 def testInvalidOverrideConstructsInCc(self): | |
450 mock_input_api = MockInputApi() | |
451 lines = ['foo3() override FINAL;'] | |
452 mock_file_cc = MockFile('something.cc', lines) | |
453 mock_input_api.files = [mock_file_cc] | |
454 errors = PRESUBMIT._CheckForOverrideAndFinalRules(mock_input_api, | |
455 MockOutputApi()) | |
456 self.assertEqual(1, len(errors)) | |
457 | |
458 def testInvalidOverrideConstructsInMm(self): | |
459 mock_input_api = MockInputApi() | |
460 lines = ['foo4() OVERRIDE final;'] | |
461 mock_file_mm = MockFile('something.mm', lines) | |
462 mock_input_api.files = [mock_file_mm] | |
463 errors = PRESUBMIT._CheckForOverrideAndFinalRules(mock_input_api, | |
464 MockOutputApi()) | |
465 self.assertEqual(1, len(errors)) | |
466 | |
467 | |
416 class InvalidIfDefinedMacroNamesTest(unittest.TestCase): | 468 class InvalidIfDefinedMacroNamesTest(unittest.TestCase): |
417 def testInvalidIfDefinedMacroNames(self): | 469 def testInvalidIfDefinedMacroNames(self): |
418 lines = ['#if defined(TARGET_IPHONE_SIMULATOR)', | 470 lines = ['#if defined(TARGET_IPHONE_SIMULATOR)', |
419 '#if !defined(TARGET_IPHONE_SIMULATOR)', | 471 '#if !defined(TARGET_IPHONE_SIMULATOR)', |
420 '#elif defined(TARGET_IPHONE_SIMULATOR)', | 472 '#elif defined(TARGET_IPHONE_SIMULATOR)', |
421 '#ifdef TARGET_IPHONE_SIMULATOR', | 473 '#ifdef TARGET_IPHONE_SIMULATOR', |
422 ' # ifdef TARGET_IPHONE_SIMULATOR', | 474 ' # ifdef TARGET_IPHONE_SIMULATOR', |
423 '# if defined(VALID) || defined(TARGET_IPHONE_SIMULATOR)', | 475 '# if defined(VALID) || defined(TARGET_IPHONE_SIMULATOR)', |
424 '# else // defined(TARGET_IPHONE_SIMULATOR)', | 476 '# else // defined(TARGET_IPHONE_SIMULATOR)', |
425 '#endif // defined(TARGET_IPHONE_SIMULATOR)',] | 477 '#endif // defined(TARGET_IPHONE_SIMULATOR)',] |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
778 } | 830 } |
779 for master, bots in bots.iteritems(): | 831 for master, bots in bots.iteritems(): |
780 for bot in bots: | 832 for bot in bots: |
781 self.assertEqual(master, PRESUBMIT.GetTryServerMasterForBot(bot), | 833 self.assertEqual(master, PRESUBMIT.GetTryServerMasterForBot(bot), |
782 'bot=%s: expected %s, computed %s' % ( | 834 'bot=%s: expected %s, computed %s' % ( |
783 bot, master, PRESUBMIT.GetTryServerMasterForBot(bot))) | 835 bot, master, PRESUBMIT.GetTryServerMasterForBot(bot))) |
784 | 836 |
785 | 837 |
786 if __name__ == '__main__': | 838 if __name__ == '__main__': |
787 unittest.main() | 839 unittest.main() |
OLD | NEW |