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

Unified Diff: tests/presubmit_unittest.py

Issue 8059009: Support for |change| argument to |GetPreferredTrySlaves()|, try 2. (Closed) Base URL: http://src.chromium.org/svn/trunk/tools/depot_tools/
Patch Set: '' Created 9 years, 3 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
Index: tests/presubmit_unittest.py
===================================================================
--- tests/presubmit_unittest.py (revision 102922)
+++ tests/presubmit_unittest.py (working copy)
@@ -153,7 +153,7 @@
'OutputApi', 'ParseFiles', 'PresubmitFailure',
'PresubmitExecuter', 'PresubmitOutput', 'ScanSubDirs',
'SvnAffectedFile', 'SvnChange', 'cPickle', 'cStringIO',
- 'fix_encoding', 'fnmatch', 'gclient_utils', 'glob', 'json',
+ 'fix_encoding', 'fnmatch', 'gclient_utils', 'glob', 'inspect', 'json',
'load_files',
'logging', 'marshal', 'normpath', 'optparse', 'os', 'owners', 'pickle',
'presubmit_canned_checks', 'random', 're', 'rietveld', 'scm',
@@ -669,11 +669,18 @@
def testGetTrySlavesExecuter(self):
self.mox.ReplayAll()
-
+ change = presubmit.Change(
+ 'foo',
+ 'Blah Blah\n\nSTORY=http://tracker.com/42\nBUG=boo\n',
+ self.fake_root_dir,
+ None,
+ 0,
+ 0,
+ None)
executer = presubmit.GetTrySlavesExecuter()
- self.assertEqual([], executer.ExecPresubmitScript('', '', ''))
- self.assertEqual(
- [], executer.ExecPresubmitScript('def foo():\n return\n', '', ''))
+ self.assertEqual([], executer.ExecPresubmitScript('', '', '', change))
+ self.assertEqual([],
+ executer.ExecPresubmitScript('def foo():\n return\n', '', '', change))
# bad results
starts_with_space_result = [' starts_with_space']
@@ -682,7 +689,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, '', '', change)
# good results
expected_result = ['1', '2', '3']
@@ -692,20 +699,31 @@
self.assertEqual(
result,
executer.ExecPresubmitScript(
- self.presubmit_tryslave % result, '', ''))
+ self.presubmit_tryslave % result, '', '', change))
def testGetTrySlavesExecuterWithProject(self):
self.mox.ReplayAll()
+ change = presubmit.Change(
+ 'foo',
+ 'Blah Blah\n\nSTORY=http://tracker.com/42\nBUG=boo\n',
+ self.fake_root_dir,
+ None,
+ 0,
+ 0,
+ None)
+
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'))
+ expected_result1, executer.ExecPresubmitScript(script, '', 'foo',
+ change))
self.assertEqual(
- expected_result2, executer.ExecPresubmitScript(script, '', 'bar'))
+ expected_result2, executer.ExecPresubmitScript(script, '', 'bar',
+ change))
def testDoGetTrySlaves(self):
join = presubmit.os.path.join
@@ -730,13 +748,18 @@
self.presubmit_tryslave % '["linux"]')
self.mox.ReplayAll()
+ change = presubmit.Change(
+ 'mychange', '', self.fake_root_dir, [], 0, 0, None)
+
output = StringIO.StringIO()
self.assertEqual(['win'],
- presubmit.DoGetTrySlaves([filename], self.fake_root_dir,
+ presubmit.DoGetTrySlaves(change, [filename],
+ self.fake_root_dir,
None, None, False, output))
output = StringIO.StringIO()
self.assertEqual(['win', 'linux'],
- presubmit.DoGetTrySlaves([filename, filename_linux],
+ presubmit.DoGetTrySlaves(change,
+ [filename, filename_linux],
self.fake_root_dir, None, None,
False, output))
« no previous file with comments | « presubmit_support.py ('k') | tests/trychange_unittest.py » ('j') | trychange.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698