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

Unified Diff: tests/presubmit_unittest.py

Issue 7062012: Fixing unit tests to match --project changes. (Closed) Base URL: svn://chrome-svn/chrome/trunk/tools/depot_tools/
Patch Set: '' Created 9 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/presubmit_unittest.py
===================================================================
--- tests/presubmit_unittest.py (revision 86301)
+++ tests/presubmit_unittest.py (working copy)
@@ -39,6 +39,14 @@
return %s
"""
+ presubmit_tryslave_project = """
+def GetPreferredTrySlaves(project):
+ if project == %s:
+ return %s
+ else:
+ return %s
+"""
+
presubmit_diffs = """
--- file1 2011-02-09 10:38:16.517224845 -0800
+++ file2 2011-02-09 10:38:53.177226516 -0800
@@ -661,9 +669,9 @@
self.mox.ReplayAll()
executer = presubmit.GetTrySlavesExecuter()
- self.assertEqual([], executer.ExecPresubmitScript('', ''))
+ self.assertEqual([], executer.ExecPresubmitScript('', '', ''))
self.assertEqual(
- [], executer.ExecPresubmitScript('def foo():\n return\n', ''))
+ [], executer.ExecPresubmitScript('def foo():\n return\n', '', ''))
# bad results
starts_with_space_result = [' starts_with_space']
@@ -672,7 +680,7 @@
for result in starts_with_space_result, not_list_result1, not_list_result2:
self.assertRaises(presubmit.PresubmitFailure,
executer.ExecPresubmitScript,
- self.presubmit_tryslave % result, '')
+ self.presubmit_tryslave % result, '', '')
# good results
expected_result = ['1', '2', '3']
@@ -681,8 +689,22 @@
for result in expected_result, empty_result, space_in_name_result:
self.assertEqual(
result,
- executer.ExecPresubmitScript(self.presubmit_tryslave % result, ''))
+ executer.ExecPresubmitScript(
+ self.presubmit_tryslave % result, '', ''))
+ def testGetTrySlavesExecuterWithProject(self):
+ self.mox.ReplayAll()
+
+ executer = presubmit.GetTrySlavesExecuter()
+ expected_result1 = ['1', '2']
+ expected_result2 = ['a', 'b', 'c']
+ script = self.presubmit_tryslave_project % (
+ repr('foo'), repr(expected_result1), repr(expected_result2))
+ self.assertEqual(
+ expected_result1, executer.ExecPresubmitScript(script, '', 'foo'))
+ self.assertEqual(
+ expected_result2, executer.ExecPresubmitScript(script, '', 'bar'))
+
def testDoGetTrySlaves(self):
join = presubmit.os.path.join
filename = 'foo.cc'
@@ -709,12 +731,12 @@
output = StringIO.StringIO()
self.assertEqual(['win'],
presubmit.DoGetTrySlaves([filename], self.fake_root_dir,
- None, False, output))
+ None, None, False, output))
output = StringIO.StringIO()
self.assertEqual(['win', 'linux'],
presubmit.DoGetTrySlaves([filename, filename_linux],
- self.fake_root_dir, None, False,
- output))
+ self.fake_root_dir, None, None,
+ False, output))
def testMainUnversioned(self):
# OptParser calls presubmit.os.path.exists and is a pain when mocked.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698