| 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 functools | 10 import functools |
| (...skipping 905 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 916 None) | 916 None) |
| 917 executer = presubmit.GetTrySlavesExecuter() | 917 executer = presubmit.GetTrySlavesExecuter() |
| 918 self.assertEqual([], executer.ExecPresubmitScript('', '', '', change)) | 918 self.assertEqual([], executer.ExecPresubmitScript('', '', '', change)) |
| 919 self.assertEqual([], | 919 self.assertEqual([], |
| 920 executer.ExecPresubmitScript('def foo():\n return\n', '', '', change)) | 920 executer.ExecPresubmitScript('def foo():\n return\n', '', '', change)) |
| 921 | 921 |
| 922 # bad results | 922 # bad results |
| 923 starts_with_space_result = [' starts_with_space'] | 923 starts_with_space_result = [' starts_with_space'] |
| 924 not_list_result1 = "'foo'" | 924 not_list_result1 = "'foo'" |
| 925 not_list_result2 = "('a', 'tuple')" | 925 not_list_result2 = "('a', 'tuple')" |
| 926 for result in starts_with_space_result, not_list_result1, not_list_result2: | 926 mixed_old_and_new = ['bot', ('bot2', set(['test']))] |
| 927 not_set = [('bot2', ['test'])] |
| 928 for result in ( |
| 929 starts_with_space_result, not_list_result1, not_list_result2, |
| 930 mixed_old_and_new, not_set): |
| 927 self.assertRaises(presubmit.PresubmitFailure, | 931 self.assertRaises(presubmit.PresubmitFailure, |
| 928 executer.ExecPresubmitScript, | 932 executer.ExecPresubmitScript, |
| 929 self.presubmit_tryslave % result, '', '', change) | 933 self.presubmit_tryslave % result, '', '', change) |
| 930 | 934 |
| 931 # good results | 935 # good results |
| 932 expected_result = ['1', '2', '3'] | 936 expected_result = ['1', '2', '3'] |
| 933 empty_result = [] | 937 empty_result = [] |
| 934 space_in_name_result = ['foo bar', '1\t2 3'] | 938 space_in_name_result = ['foo bar', '1\t2 3'] |
| 935 for result in expected_result, empty_result, space_in_name_result: | 939 new_style = [('bot', set(['cool', 'tests']))] |
| 940 for result in ( |
| 941 expected_result, empty_result, space_in_name_result, new_style): |
| 936 self.assertEqual( | 942 self.assertEqual( |
| 937 result, | 943 result, |
| 938 executer.ExecPresubmitScript( | 944 executer.ExecPresubmitScript( |
| 939 self.presubmit_tryslave % result, '', '', change)) | 945 self.presubmit_tryslave % result, '', '', change)) |
| 940 | 946 |
| 941 def testGetTrySlavesExecuterWithProject(self): | 947 def testGetTrySlavesExecuterWithProject(self): |
| 942 self.mox.ReplayAll() | 948 self.mox.ReplayAll() |
| 943 | 949 |
| 944 change = presubmit.Change( | 950 change = presubmit.Change( |
| 945 'foo', | 951 'foo', |
| (...skipping 1788 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2734 owners_check=False) | 2740 owners_check=False) |
| 2735 self.assertEqual(1, len(results)) | 2741 self.assertEqual(1, len(results)) |
| 2736 self.assertEqual( | 2742 self.assertEqual( |
| 2737 'Found line ending with white spaces in:', results[0]._message) | 2743 'Found line ending with white spaces in:', results[0]._message) |
| 2738 self.checkstdout('') | 2744 self.checkstdout('') |
| 2739 | 2745 |
| 2740 | 2746 |
| 2741 if __name__ == '__main__': | 2747 if __name__ == '__main__': |
| 2742 import unittest | 2748 import unittest |
| 2743 unittest.main() | 2749 unittest.main() |
| OLD | NEW |