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

Side by Side Diff: tests/presubmit_unittest.py

Issue 9664015: Adds saner behavior for git try -t foo to not fail in a inexplicable way. Enforces that each builde… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: improve comment Created 8 years, 9 months 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 | Annotate | Revision Log
« 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 logging 10 import logging
(...skipping 774 matching lines...) Expand 10 before | Expand all | Expand 10 after
785 presubmit.DoGetTrySlaves(change, [filename], 785 presubmit.DoGetTrySlaves(change, [filename],
786 self.fake_root_dir, 786 self.fake_root_dir,
787 None, None, False, output)) 787 None, None, False, output))
788 output = StringIO.StringIO() 788 output = StringIO.StringIO()
789 self.assertEqual(['win', 'linux'], 789 self.assertEqual(['win', 'linux'],
790 presubmit.DoGetTrySlaves(change, 790 presubmit.DoGetTrySlaves(change,
791 [filename, filename_linux], 791 [filename, filename_linux],
792 self.fake_root_dir, None, None, 792 self.fake_root_dir, None, None,
793 False, output)) 793 False, output))
794 794
795 def testGetTrySlavesExecuter_ok(self):
796 script_text = (
797 'def GetPreferredTrySlaves():\n'
798 ' return ["foo", "bar"]\n')
799 results = presubmit.GetTrySlavesExecuter.ExecPresubmitScript(
800 script_text, 'path', 'project', None)
801 self.assertEquals(['foo', 'bar'], results)
802
803 def testGetTrySlavesExecuter_comma(self):
804 script_text = (
805 'def GetPreferredTrySlaves():\n'
806 ' return ["foo,bar"]\n')
807 try:
808 presubmit.GetTrySlavesExecuter.ExecPresubmitScript(
809 script_text, 'path', 'project', None)
810 self.fail()
811 except presubmit.PresubmitFailure:
812 pass
813
795 def testMainUnversioned(self): 814 def testMainUnversioned(self):
796 # OptParser calls presubmit.os.path.exists and is a pain when mocked. 815 # OptParser calls presubmit.os.path.exists and is a pain when mocked.
797 self.UnMock(presubmit.os.path, 'exists') 816 self.UnMock(presubmit.os.path, 'exists')
798 self.mox.StubOutWithMock(presubmit, 'DoPresubmitChecks') 817 self.mox.StubOutWithMock(presubmit, 'DoPresubmitChecks')
799 self.mox.StubOutWithMock(presubmit, 'ParseFiles') 818 self.mox.StubOutWithMock(presubmit, 'ParseFiles')
800 presubmit.scm.determine_scm(self.fake_root_dir).AndReturn(None) 819 presubmit.scm.determine_scm(self.fake_root_dir).AndReturn(None)
801 presubmit.ParseFiles(['random_file.txt'], None 820 presubmit.ParseFiles(['random_file.txt'], None
802 ).AndReturn([('M', 'random_file.txt')]) 821 ).AndReturn([('M', 'random_file.txt')])
803 output = self.mox.CreateMock(presubmit.PresubmitOutput) 822 output = self.mox.CreateMock(presubmit.PresubmitOutput)
804 output.should_continue().AndReturn(False) 823 output.should_continue().AndReturn(False)
(...skipping 1560 matching lines...) Expand 10 before | Expand all | Expand 10 after
2365 owners_check=False) 2384 owners_check=False)
2366 self.assertEqual(1, len(results)) 2385 self.assertEqual(1, len(results))
2367 self.assertEqual( 2386 self.assertEqual(
2368 'Found line ending with white spaces in:', results[0]._message) 2387 'Found line ending with white spaces in:', results[0]._message)
2369 self.checkstdout('') 2388 self.checkstdout('')
2370 2389
2371 2390
2372 if __name__ == '__main__': 2391 if __name__ == '__main__':
2373 import unittest 2392 import unittest
2374 unittest.main() 2393 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