| 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 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 | 377 |
| 378 def testOnlyOwnersFiles(self): | 378 def testOnlyOwnersFiles(self): |
| 379 mock_change = MockChange([ | 379 mock_change = MockChange([ |
| 380 'some/path/OWNERS', | 380 'some/path/OWNERS', |
| 381 'A\Windows\Path\OWNERS', | 381 'A\Windows\Path\OWNERS', |
| 382 ]) | 382 ]) |
| 383 results = PRESUBMIT.GetPreferredTryMasters(None, mock_change) | 383 results = PRESUBMIT.GetPreferredTryMasters(None, mock_change) |
| 384 self.assertEqual({}, results) | 384 self.assertEqual({}, results) |
| 385 | 385 |
| 386 | 386 |
| 387 class CheckSingletonInHeadersTest(unittest.TestCase): |
| 388 def testSingletonInArbitraryHeader(self): |
| 389 diff_singleton_h = ['base::subtle::AtomicWord ' |
| 390 'Singleton<Type, Traits, DifferentiatingType>::'] |
| 391 diff_foo_h = ['// Singleton<Foo> in comment.', |
| 392 'friend class Singleton<Foo>'] |
| 393 diff_bad_h = ['Foo* foo = Singleton<Foo>::get();'] |
| 394 mock_input_api = MockInputApi() |
| 395 mock_input_api.files = [MockFile('base/memory/singleton.h', |
| 396 diff_singleton_h), |
| 397 MockFile('foo.h', diff_foo_h), |
| 398 MockFile('bad.h', diff_bad_h)] |
| 399 warnings = PRESUBMIT._CheckSingletonInHeaders(mock_input_api, |
| 400 MockOutputApi()) |
| 401 self.assertEqual(1, len(warnings)) |
| 402 self.assertEqual('error', warnings[0].type) |
| 403 self.assertTrue('Found Singleton<T>' in warnings[0].message) |
| 404 |
| 405 def testSingletonInCC(self): |
| 406 diff_cc = ['Foo* foo = Singleton<Foo>::get();'] |
| 407 mock_input_api = MockInputApi() |
| 408 mock_input_api.files = [MockFile('some/path/foo.cc', diff_cc)] |
| 409 warnings = PRESUBMIT._CheckSingletonInHeaders(mock_input_api, |
| 410 MockOutputApi()) |
| 411 self.assertEqual(0, len(warnings)) |
| 412 |
| 413 |
| 387 class InvalidOSMacroNamesTest(unittest.TestCase): | 414 class InvalidOSMacroNamesTest(unittest.TestCase): |
| 388 def testInvalidOSMacroNames(self): | 415 def testInvalidOSMacroNames(self): |
| 389 lines = ['#if defined(OS_WINDOWS)', | 416 lines = ['#if defined(OS_WINDOWS)', |
| 390 ' #elif defined(OS_WINDOW)', | 417 ' #elif defined(OS_WINDOW)', |
| 391 ' # if defined(OS_MACOSX) || defined(OS_CHROME)', | 418 ' # if defined(OS_MACOSX) || defined(OS_CHROME)', |
| 392 '# else // defined(OS_MAC)', | 419 '# else // defined(OS_MAC)', |
| 393 '#endif // defined(OS_MACOS)'] | 420 '#endif // defined(OS_MACOS)'] |
| 394 errors = PRESUBMIT._CheckForInvalidOSMacrosInFile( | 421 errors = PRESUBMIT._CheckForInvalidOSMacrosInFile( |
| 395 MockInputApi(), MockFile('some/path/foo_platform.cc', lines)) | 422 MockInputApi(), MockFile('some/path/foo_platform.cc', lines)) |
| 396 self.assertEqual(len(lines), len(errors)) | 423 self.assertEqual(len(lines), len(errors)) |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 755 } | 782 } |
| 756 for master, bots in bots.iteritems(): | 783 for master, bots in bots.iteritems(): |
| 757 for bot in bots: | 784 for bot in bots: |
| 758 self.assertEqual(master, PRESUBMIT.GetTryServerMasterForBot(bot), | 785 self.assertEqual(master, PRESUBMIT.GetTryServerMasterForBot(bot), |
| 759 'bot=%s: expected %s, computed %s' % ( | 786 'bot=%s: expected %s, computed %s' % ( |
| 760 bot, master, PRESUBMIT.GetTryServerMasterForBot(bot))) | 787 bot, master, PRESUBMIT.GetTryServerMasterForBot(bot))) |
| 761 | 788 |
| 762 | 789 |
| 763 if __name__ == '__main__': | 790 if __name__ == '__main__': |
| 764 unittest.main() | 791 unittest.main() |
| OLD | NEW |