Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(303)

Side by Side Diff: tests/presubmit_unittest.py

Issue 74163002: Allow PRESUBMIT.py files to have old and new-style trybot specifications (as long as each file is c… (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Address maruel nits. Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « presubmit_support.py ('k') | trychange.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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()
OLDNEW
« no previous file with comments | « presubmit_support.py ('k') | trychange.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698