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 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 '=======', | 339 '=======', |
340 ' ScopedTempDir temp_dir_;', | 340 ' ScopedTempDir temp_dir_;', |
341 '>>>>>>> master'] | 341 '>>>>>>> master'] |
342 errors = PRESUBMIT._CheckForVersionControlConflictsInFile( | 342 errors = PRESUBMIT._CheckForVersionControlConflictsInFile( |
343 MockInputApi(), MockFile('some/path/foo_platform.cc', lines)) | 343 MockInputApi(), MockFile('some/path/foo_platform.cc', lines)) |
344 self.assertEqual(3, len(errors)) | 344 self.assertEqual(3, len(errors)) |
345 self.assertTrue('1' in errors[0]) | 345 self.assertTrue('1' in errors[0]) |
346 self.assertTrue('3' in errors[1]) | 346 self.assertTrue('3' in errors[1]) |
347 self.assertTrue('5' in errors[2]) | 347 self.assertTrue('5' in errors[2]) |
348 | 348 |
| 349 class UmaHistogramChangeMatchedOrNotTest(unittest.TestCase): |
| 350 def testTypicalNotMatchedChange(self): |
| 351 diff = ['UMA_HISTOGRAM_BOOL("Bla.Foo.Dummy", true)'] |
| 352 mock_input_api = MockInputApi() |
| 353 mock_input_api.files = [MockFile('some/path/foo.cc', diff)] |
| 354 warnings = PRESUBMIT._CheckUmaHistogramChanges(mock_input_api, |
| 355 MockOutputApi()) |
| 356 self.assertEqual(1, len(warnings)) |
| 357 self.assertEqual('warning', warnings[0].type) |
| 358 |
| 359 def testTypicalCorrectlyMatchedChange(self): |
| 360 diff_cc = ['UMA_HISTOGRAM_BOOL("Bla.Foo.Dummy", true)'] |
| 361 diff_xml = ['<histogram name="Bla.Foo.Dummy"> </histogram>'] |
| 362 mock_input_api = MockInputApi() |
| 363 mock_input_api.files = [ |
| 364 MockFile('some/path/foo.cc', diff_cc), |
| 365 MockFile('tools/metrics/histograms/histograms.xml', diff_xml), |
| 366 ] |
| 367 warnings = [] |
| 368 warnings = PRESUBMIT._CheckUmaHistogramChanges(mock_input_api, |
| 369 MockOutputApi()) |
| 370 self.assertEqual(0, len(warnings)) |
349 | 371 |
350 class BadExtensionsTest(unittest.TestCase): | 372 class BadExtensionsTest(unittest.TestCase): |
351 def testBadRejFile(self): | 373 def testBadRejFile(self): |
352 mock_input_api = MockInputApi() | 374 mock_input_api = MockInputApi() |
353 mock_input_api.files = [ | 375 mock_input_api.files = [ |
354 MockFile('some/path/foo.cc', ''), | 376 MockFile('some/path/foo.cc', ''), |
355 MockFile('some/path/foo.cc.rej', ''), | 377 MockFile('some/path/foo.cc.rej', ''), |
356 MockFile('some/path2/bar.h.rej', ''), | 378 MockFile('some/path2/bar.h.rej', ''), |
357 ] | 379 ] |
358 | 380 |
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
768 } | 790 } |
769 for master, bots in bots.iteritems(): | 791 for master, bots in bots.iteritems(): |
770 for bot in bots: | 792 for bot in bots: |
771 self.assertEqual(master, PRESUBMIT.GetTryServerMasterForBot(bot), | 793 self.assertEqual(master, PRESUBMIT.GetTryServerMasterForBot(bot), |
772 'bot=%s: expected %s, computed %s' % ( | 794 'bot=%s: expected %s, computed %s' % ( |
773 bot, master, PRESUBMIT.GetTryServerMasterForBot(bot))) | 795 bot, master, PRESUBMIT.GetTryServerMasterForBot(bot))) |
774 | 796 |
775 | 797 |
776 if __name__ == '__main__': | 798 if __name__ == '__main__': |
777 unittest.main() | 799 unittest.main() |
OLD | NEW |