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

Unified Diff: presubmit_support.py

Issue 54373011: Rework bot and test parsing to allow receipt of (bot, set(test)) specifications. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Final changes. Created 7 years, 1 month 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 | tests/trychange_unittest.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 8f3575cefca5f2f17706a9cb790141ba35f28b8d..345c78eb6b8ec7caa676e7d6c0d624e737eafa70 100755
--- a/presubmit_support.py
+++ b/presubmit_support.py
@@ -6,7 +6,7 @@
"""Enables directory-specific presubmit checks to run at upload and/or commit.
"""
-__version__ = '1.6.2'
+__version__ = '1.7.0'
# TODO(joi) Add caching where appropriate/needed. The API is designed to allow
# caching (between all different invocations of presubmit scripts for a given
@@ -1031,14 +1031,22 @@ class GetTrySlavesExecuter(object):
'Presubmit functions must return a list, got a %s instead: %s' %
(type(result), str(result)))
for item in result:
- if not isinstance(item, basestring):
- raise PresubmitFailure('All try slaves names must be strings.')
- if item != item.strip():
+ 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 item:
+ if ',' in botname:
raise PresubmitFailure(
- 'Do not use \',\' separated builder or test names: %s' % item)
+ 'Do not use \',\' separated builder or test names: %s' % botname)
else:
result = []
return result
@@ -1084,7 +1092,18 @@ def DoGetTrySlaves(change,
results += executer.ExecPresubmitScript(
presubmit_script, filename, project, change)
- slaves = list(set(results))
+ if all(isinstance(i, tuple) for i in results):
+ # New-style [('bot', set(['tests']))] format.
+ slave_dict = {}
+ for result in results:
+ slave_dict.setdefault(result[0], set()).update(result[1])
+ slaves = list(slave_dict.iteritems())
+ elif all(isinstance(i, basestring) for i in results):
+ # Old-style ['bot'] format.
+ slaves = list(set(results))
+ else:
+ raise ValueError('PRESUBMIT.py returned invalid trybot specification!')
+
if slaves and verbose:
output_stream.write(', '.join(slaves))
output_stream.write('\n')
« no previous file with comments | « no previous file | tests/trychange_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698