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

Unified Diff: presubmit_support.py

Issue 2453823002: depot_tools: Remove DoGetTrySlaves, GetTrySlavesExecuter, GetPreferredTrySlaves (Closed)
Patch Set: Rebase Created 4 years, 2 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 | « git_cl.py ('k') | tests/git_cl_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: presubmit_support.py
diff --git a/presubmit_support.py b/presubmit_support.py
index fe3de7b05907f51e080b2093623f0b573c13fc0c..ca54dd14b3de5226e9d56b4c7118ac61d515941c 100755
--- a/presubmit_support.py
+++ b/presubmit_support.py
@@ -1084,83 +1084,6 @@ def ListRelevantPresubmitFiles(files, root):
return results
-class GetTrySlavesExecuter(object):
- @staticmethod
- def ExecPresubmitScript(script_text, presubmit_path, project, change):
- """Executes GetPreferredTrySlaves() from a single presubmit script.
-
- This will soon be deprecated and replaced by GetPreferredTryMasters().
-
- 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 = {}
- main_path = os.getcwd()
- try:
- os.chdir(os.path.dirname(presubmit_path))
- exec script_text in context
- except Exception, e:
- raise PresubmitFailure('"%s" had an exception.\n%s' % (presubmit_path, e))
- finally:
- os.chdir(main_path)
-
- function_name = 'GetPreferredTrySlaves'
- if function_name in context:
- get_preferred_try_slaves = context[function_name]
- function_info = inspect.getargspec(get_preferred_try_slaves)
- if len(function_info[0]) == 1:
- result = get_preferred_try_slaves(project)
- elif len(function_info[0]) == 2:
- result = get_preferred_try_slaves(project, change)
- else:
- result = get_preferred_try_slaves()
- if not isinstance(result, types.ListType):
- raise PresubmitFailure(
- 'Presubmit functions must return a list, got a %s instead: %s' %
- (type(result), str(result)))
- for item in result:
- if isinstance(item, basestring):
- # Old-style ['bot'] format.
- botname = item
- elif isinstance(item, tuple):
- # New-style [('bot', set(['tests']))] format.
- botname = item[0]
- else:
- raise PresubmitFailure('PRESUBMIT.py returned invalid tryslave/test'
- ' format.')
-
- if botname != botname.strip():
- raise PresubmitFailure(
- 'Try slave names cannot start/end with whitespace')
- if ',' in botname:
- raise PresubmitFailure(
- 'Do not use \',\' separated builder or test names: %s' % botname)
- else:
- result = []
-
- def valid_oldstyle(result):
- return all(isinstance(i, basestring) for i in result)
-
- def valid_newstyle(result):
- return (all(isinstance(i, tuple) for i in result) and
- all(len(i) == 2 for i in result) and
- all(isinstance(i[0], basestring) for i in result) and
- all(isinstance(i[1], set) for i in result)
- )
-
- # Ensure it's either all old-style or all new-style.
- if not valid_oldstyle(result) and not valid_newstyle(result):
- raise PresubmitFailure(
- 'PRESUBMIT.py returned invalid trybot specification!')
-
- return result
-
-
class GetTryMastersExecuter(object):
@staticmethod
def ExecPresubmitScript(script_text, presubmit_path, project, change):
@@ -1222,64 +1145,6 @@ class GetPostUploadExecuter(object):
return post_upload_hook(cl, change, OutputApi(False))
-def DoGetTrySlaves(change,
- changed_files,
- repository_root,
- default_presubmit,
- project,
- verbose,
- output_stream):
- """Get the list of try servers from the presubmit scripts (deprecated).
-
- Args:
- 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.
-
- Return:
- List of try slaves
- """
- presubmit_files = ListRelevantPresubmitFiles(changed_files, repository_root)
- if not presubmit_files and verbose:
- output_stream.write("Warning, no PRESUBMIT.py found.\n")
- results = []
- executer = GetTrySlavesExecuter()
-
- if default_presubmit:
- if verbose:
- output_stream.write("Running default presubmit script.\n")
- fake_path = os.path.join(repository_root, 'PRESUBMIT.py')
- results.extend(executer.ExecPresubmitScript(
- default_presubmit, fake_path, project, change))
- 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.extend(executer.ExecPresubmitScript(
- presubmit_script, filename, project, change))
-
-
- slave_dict = {}
- old_style = filter(lambda x: isinstance(x, basestring), results)
- new_style = filter(lambda x: isinstance(x, tuple), results)
-
- for result in new_style:
- slave_dict.setdefault(result[0], set()).update(result[1])
- slaves = list(slave_dict.items())
-
- slaves.extend(set(old_style))
-
- if slaves and verbose:
- output_stream.write(', '.join((str(x) for x in slaves)))
- output_stream.write('\n')
- return slaves
-
-
def _MergeMasters(masters1, masters2):
"""Merges two master maps. Merges also the tests of each builder."""
result = {}
« no previous file with comments | « git_cl.py ('k') | tests/git_cl_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698