| 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 """Unit tests for presubmit_support.py and presubmit_canned_checks.py.""" | 6 """Unit tests for presubmit_support.py and presubmit_canned_checks.py.""" |
| 7 | 7 |
| 8 # pylint: disable=E1101,E1103 | 8 # pylint: disable=E1101,E1103 |
| 9 | 9 |
| 10 import logging | 10 import logging |
| (...skipping 1489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1500 'CheckChangeHasQaField', 'CheckChangeHasTestedField', | 1500 'CheckChangeHasQaField', 'CheckChangeHasTestedField', |
| 1501 'CheckChangeHasTestField', | 1501 'CheckChangeHasTestField', |
| 1502 'CheckChangeLintsClean', | 1502 'CheckChangeLintsClean', |
| 1503 'CheckChangeSvnEolStyle', | 1503 'CheckChangeSvnEolStyle', |
| 1504 'CheckChangeWasUploaded', | 1504 'CheckChangeWasUploaded', |
| 1505 'CheckDoNotSubmit', | 1505 'CheckDoNotSubmit', |
| 1506 'CheckDoNotSubmitInDescription', 'CheckDoNotSubmitInFiles', | 1506 'CheckDoNotSubmitInDescription', 'CheckDoNotSubmitInFiles', |
| 1507 'CheckLongLines', 'CheckTreeIsOpen', 'PanProjectChecks', | 1507 'CheckLongLines', 'CheckTreeIsOpen', 'PanProjectChecks', |
| 1508 'CheckLicense', | 1508 'CheckLicense', |
| 1509 'CheckOwners', | 1509 'CheckOwners', |
| 1510 'CheckIssueNotClosed', | |
| 1511 'CheckRietveldTryJobExecution', | 1510 'CheckRietveldTryJobExecution', |
| 1512 'CheckSingletonInHeaders', | 1511 'CheckSingletonInHeaders', |
| 1513 'CheckSvnModifiedDirectories', | 1512 'CheckSvnModifiedDirectories', |
| 1514 'CheckSvnForCommonMimeTypes', 'CheckSvnProperty', | 1513 'CheckSvnForCommonMimeTypes', 'CheckSvnProperty', |
| 1515 'RunPythonUnitTests', 'RunPylint', | 1514 'RunPythonUnitTests', 'RunPylint', |
| 1516 'RunUnitTests', 'RunUnitTestsInDirectory', | 1515 'RunUnitTests', 'RunUnitTestsInDirectory', |
| 1517 ] | 1516 ] |
| 1518 # If this test fails, you should add the relevant test. | 1517 # If this test fails, you should add the relevant test. |
| 1519 self.compareMembers(presubmit_canned_checks, members) | 1518 self.compareMembers(presubmit_canned_checks, members) |
| 1520 | 1519 |
| (...skipping 868 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2389 'directories:\n' | 2388 'directories:\n' |
| 2390 ' foo\n') | 2389 ' foo\n') |
| 2391 | 2390 |
| 2392 def testCannedCheckOwners_WithLGTMs(self): | 2391 def testCannedCheckOwners_WithLGTMs(self): |
| 2393 self.AssertOwnersWorks(approvers=set(['ben@example.com']), | 2392 self.AssertOwnersWorks(approvers=set(['ben@example.com']), |
| 2394 uncovered_dirs=set()) | 2393 uncovered_dirs=set()) |
| 2395 self.AssertOwnersWorks(approvers=set(['ben@example.com']), | 2394 self.AssertOwnersWorks(approvers=set(['ben@example.com']), |
| 2396 is_committing=False, | 2395 is_committing=False, |
| 2397 uncovered_dirs=set()) | 2396 uncovered_dirs=set()) |
| 2398 | 2397 |
| 2399 def CheckIssueClosedBase(self, closed): | |
| 2400 input_api = self.MockInputApi( | |
| 2401 presubmit.Change('', '', None, None, 1, 0, None), False) | |
| 2402 input_api.rietveld.get_issue_properties( | |
| 2403 issue=int(input_api.change.issue), messages=False).AndReturn( | |
| 2404 {'closed': closed, 'issue': 1}) | |
| 2405 self.mox.ReplayAll() | |
| 2406 return presubmit_canned_checks.CheckIssueNotClosed( | |
| 2407 input_api, presubmit.OutputApi) | |
| 2408 | |
| 2409 def testIssueOpen(self): | |
| 2410 self.assertEqual([], self.CheckIssueClosedBase(False)) | |
| 2411 | |
| 2412 def testIssueClosed(self): | |
| 2413 results = self.CheckIssueClosedBase(True) | |
| 2414 self.assertEqual(len(results), 1) | |
| 2415 self.assertTrue(results[0].fatal) | |
| 2416 | |
| 2417 def testCannedRunUnitTests(self): | 2398 def testCannedRunUnitTests(self): |
| 2418 change = presubmit.Change( | 2399 change = presubmit.Change( |
| 2419 'foo1', 'description1', self.fake_root_dir, None, 0, 0, None) | 2400 'foo1', 'description1', self.fake_root_dir, None, 0, 0, None) |
| 2420 input_api = self.MockInputApi(change, False) | 2401 input_api = self.MockInputApi(change, False) |
| 2421 input_api.verbose = True | 2402 input_api.verbose = True |
| 2422 unit_tests = ['allo', 'bar.py'] | 2403 unit_tests = ['allo', 'bar.py'] |
| 2423 input_api.PresubmitLocalPath().AndReturn(self.fake_root_dir) | 2404 input_api.PresubmitLocalPath().AndReturn(self.fake_root_dir) |
| 2424 input_api.PresubmitLocalPath().AndReturn(self.fake_root_dir) | 2405 input_api.PresubmitLocalPath().AndReturn(self.fake_root_dir) |
| 2425 input_api.subprocess.check_call( | 2406 input_api.subprocess.check_call( |
| 2426 ['allo', '--verbose'], cwd=self.fake_root_dir) | 2407 ['allo', '--verbose'], cwd=self.fake_root_dir) |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2504 owners_check=False) | 2485 owners_check=False) |
| 2505 self.assertEqual(1, len(results)) | 2486 self.assertEqual(1, len(results)) |
| 2506 self.assertEqual( | 2487 self.assertEqual( |
| 2507 'Found line ending with white spaces in:', results[0]._message) | 2488 'Found line ending with white spaces in:', results[0]._message) |
| 2508 self.checkstdout('') | 2489 self.checkstdout('') |
| 2509 | 2490 |
| 2510 | 2491 |
| 2511 if __name__ == '__main__': | 2492 if __name__ == '__main__': |
| 2512 import unittest | 2493 import unittest |
| 2513 unittest.main() | 2494 unittest.main() |
| OLD | NEW |