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 InvalidIfDefinedMacroNamesTest(unittest.TestCase): |
| 417 def testInvalidIfDefinedMacroNames(self): |
| 418 lines = ['#if defined(TARGET_IPHONE_SIMULATOR)', |
| 419 '#if !defined(TARGET_IPHONE_SIMULATOR)', |
| 420 '#elif defined(TARGET_IPHONE_SIMULATOR)', |
| 421 '#ifdef TARGET_IPHONE_SIMULATOR', |
| 422 ' # ifdef TARGET_IPHONE_SIMULATOR', |
| 423 '# if defined(VALID) || defined(TARGET_IPHONE_SIMULATOR)', |
| 424 '# else // defined(TARGET_IPHONE_SIMULATOR)', |
| 425 '#endif // defined(TARGET_IPHONE_SIMULATOR)',] |
| 426 errors = PRESUBMIT._CheckForInvalidIfDefinedMacrosInFile( |
| 427 MockInputApi(), MockFile('some/path/source.mm', lines)) |
| 428 self.assertEqual(len(lines), len(errors)) |
| 429 |
| 430 def testValidIfDefinedMacroNames(self): |
| 431 lines = ['#if defined(FOO)', |
| 432 '#ifdef BAR',] |
| 433 errors = PRESUBMIT._CheckForInvalidIfDefinedMacrosInFile( |
| 434 MockInputApi(), MockFile('some/path/source.cc', lines)) |
| 435 self.assertEqual(0, len(errors)) |
| 436 |
| 437 |
416 class CheckAddedDepsHaveTetsApprovalsTest(unittest.TestCase): | 438 class CheckAddedDepsHaveTetsApprovalsTest(unittest.TestCase): |
417 def testFilesToCheckForIncomingDeps(self): | 439 def testFilesToCheckForIncomingDeps(self): |
418 changed_lines = [ | 440 changed_lines = [ |
419 '"+breakpad",', | 441 '"+breakpad",', |
420 '"+chrome/installer",', | 442 '"+chrome/installer",', |
421 '"+chrome/plugin/chrome_content_plugin_client.h",', | 443 '"+chrome/plugin/chrome_content_plugin_client.h",', |
422 '"+chrome/utility/chrome_content_utility_client.h",', | 444 '"+chrome/utility/chrome_content_utility_client.h",', |
423 '"+chromeos/chromeos_paths.h",', | 445 '"+chromeos/chromeos_paths.h",', |
424 '"+components/crash",', | 446 '"+components/crash",', |
425 '"+components/nacl/common",', | 447 '"+components/nacl/common",', |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
756 } | 778 } |
757 for master, bots in bots.iteritems(): | 779 for master, bots in bots.iteritems(): |
758 for bot in bots: | 780 for bot in bots: |
759 self.assertEqual(master, PRESUBMIT.GetTryServerMasterForBot(bot), | 781 self.assertEqual(master, PRESUBMIT.GetTryServerMasterForBot(bot), |
760 'bot=%s: expected %s, computed %s' % ( | 782 'bot=%s: expected %s, computed %s' % ( |
761 bot, master, PRESUBMIT.GetTryServerMasterForBot(bot))) | 783 bot, master, PRESUBMIT.GetTryServerMasterForBot(bot))) |
762 | 784 |
763 | 785 |
764 if __name__ == '__main__': | 786 if __name__ == '__main__': |
765 unittest.main() | 787 unittest.main() |
OLD | NEW |