Chromium Code Reviews| Index: presubmit_support.py |
| diff --git a/presubmit_support.py b/presubmit_support.py |
| index 345c78eb6b8ec7caa676e7d6c0d624e737eafa70..63d2988987bdfdc583fd409936c15ca50f8cbeca 100755 |
| --- a/presubmit_support.py |
| +++ b/presubmit_support.py |
| @@ -1081,31 +1081,40 @@ def DoGetTrySlaves(change, |
| if verbose: |
| output_stream.write("Running default presubmit script.\n") |
| fake_path = os.path.join(repository_root, 'PRESUBMIT.py') |
| - results += executer.ExecPresubmitScript( |
|
M-A Ruel
2013/11/15 20:09:33
I dislike using += on list anyway.
|
| + result = executer.ExecPresubmitScript( |
| default_presubmit, fake_path, project, change) |
| + if (all(isinstance(i, tuple) for i in result) or |
|
M-A Ruel
2013/11/15 20:09:33
Add a comment:
# Ensure it's either all old-style
|
| + all(isinstance(i, basestring) for i in result)): |
| + results += result |
| + else: |
| + raise ValueError('PRESUBMIT.py returned invalid trybot specification!') |
| for filename in presubmit_files: |
|
M-A Ruel
2013/11/15 20:09:33
is this missing an else: ?
ghost stip (do not use)
2013/11/22 01:24:16
I don't think so? this is how the code was before
|
| 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( |
| + result = executer.ExecPresubmitScript( |
| presubmit_script, filename, project, change) |
| + if (all(isinstance(i, tuple) for i in result) or |
| + all(isinstance(i, basestring) for i in result)): |
| + results += result |
|
M-A Ruel
2013/11/15 20:09:33
results.extend(result)
|
| + else: |
| + raise ValueError('%s returned invalid trybot specification!' % filename) |
| - 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!') |
| + |
| + 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.iteritems()) |
| + |
| + slaves += list(set(old_style)) |
| if slaves and verbose: |
| - output_stream.write(', '.join(slaves)) |
| + output_stream.write(', '.join((str(x) for x in slaves))) |
| output_stream.write('\n') |
| return slaves |