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

Unified Diff: presubmit_support.py

Issue 7063004: Allowing project name to be used to select groups of bots. (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 | trychange.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: presubmit_support.py
===================================================================
--- presubmit_support.py (revision 86301)
+++ presubmit_support.py (working copy)
@@ -869,11 +869,13 @@
class GetTrySlavesExecuter(object):
@staticmethod
- def ExecPresubmitScript(script_text, presubmit_path):
+ def ExecPresubmitScript(script_text, presubmit_path, project):
"""Executes GetPreferredTrySlaves() from a single presubmit script.
Args:
script_text: The text of the presubmit script.
+ presubmit_path: Project script to run.
+ project: Project name to pass to presubmit script for bot selection.
Return:
A list of try slaves.
@@ -886,7 +888,10 @@
function_name = 'GetPreferredTrySlaves'
if function_name in context:
- result = eval(function_name + '()', context)
+ try:
+ result = eval(function_name + '(' + repr(project) + ')', context)
+ except TypeError:
+ result = eval(function_name + '()', context)
if not isinstance(result, types.ListType):
raise PresubmitFailure(
'Presubmit functions must return a list, got a %s instead: %s' %
@@ -905,6 +910,7 @@
def DoGetTrySlaves(changed_files,
repository_root,
default_presubmit,
+ project,
verbose,
output_stream):
"""Get the list of try servers from the presubmit scripts.
@@ -913,6 +919,7 @@
changed_files: List of modified files.
repository_root: The repository root.
default_presubmit: A default presubmit script to execute in any case.
+ project: Optional name of a project used in selecting trybots.
verbose: Prints debug info.
output_stream: A stream to write debug output to.
@@ -928,14 +935,16 @@
if verbose:
output_stream.write("Running default presubmit script.\n")
fake_path = os.path.join(repository_root, 'PRESUBMIT.py')
- results += executer.ExecPresubmitScript(default_presubmit, fake_path)
+ results += executer.ExecPresubmitScript(
+ default_presubmit, fake_path, project)
for filename in presubmit_files:
filename = os.path.abspath(filename)
if verbose:
output_stream.write("Running %s\n" % filename)
# Accept CRLF presubmit script.
presubmit_script = gclient_utils.FileRead(filename, 'rU')
- results += executer.ExecPresubmitScript(presubmit_script, filename)
+ results += executer.ExecPresubmitScript(
+ presubmit_script, filename, project)
slaves = list(set(results))
if slaves and verbose:
« no previous file with comments | « no previous file | trychange.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698