Index: presubmit_support.py |
=================================================================== |
--- presubmit_support.py (revision 86301) |
+++ presubmit_support.py (working copy) |
@@ -869,16 +869,18 @@ |
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. |
""" |
- context = {} |
+ context = {'project': project} |
M-A Ruel
2011/05/24 17:29:42
I don't like relying on a global variable. I'd pre
|
try: |
exec script_text in context |
except Exception, e: |
@@ -905,6 +907,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 +916,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 +932,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: |