Chromium Code Reviews| Index: tools/auto_bisect/bisect_results_json.py |
| diff --git a/tools/auto_bisect/bisect_results_json.py b/tools/auto_bisect/bisect_results_json.py |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..38c0dacb6c8ea0c196f6a521c347f82946952f73 |
| --- /dev/null |
| +++ b/tools/auto_bisect/bisect_results_json.py |
| @@ -0,0 +1,78 @@ |
| +# Copyright 2016 The Chromium Authors. All rights reserved. |
| +# Use of this source code is governed by a BSD-style license that can be |
| +# found in the LICENSE file. |
| + |
| + |
|
qyearsley
2016/01/26 18:08:01
No need for two blank lines before the imports
chrisphan
2016/02/10 02:23:38
Done.
|
| +import bisect_utils |
| +import source_control |
| + |
| + |
| +def get(bisect_results, opts, depot_registry): |
|
prasadv
2016/02/09 21:20:38
Method names areinconsistent with other modules
chrisphan
2016/02/10 02:23:38
What are you looking for here? get_bisect_results
qyearsley
2016/02/10 02:53:53
Function names in Chromium repo are CapitalCamelCa
|
| + """Returns the results as a jsonable object.""" |
| + if opts.bisect_mode == bisect_utils.BISECT_MODE_RETURN_CODE: |
| + change = '0' |
| + else: |
| + metric = '/'.join(opts.metric) |
| + change = '%.02f%%' % bisect_results.regression_size |
| + |
| + status = 'completed' |
|
qyearsley
2016/01/26 18:08:01
Note: (As noted in another CL) previously "status"
chrisphan
2016/02/10 02:23:38
Added this check in CL/1566013002.
qyearsley
2016/02/10 02:53:53
SGTM
|
| + |
| + return { |
| + 'try_job_id': opts.try_job_id, |
| + 'bug_id': opts.bug_id, |
| + 'status': status, |
| + 'buildbot_log_url': '', # TODO(chrisphan) Get this. |
|
prasadv
2016/02/09 21:20:38
Is it possible to use bot environmental variables
chrisphan
2016/02/10 02:23:38
Thanks for that. Done.
|
| + 'bisect_bot': '', # TODO(chrisphan): Get this. |
| + 'command': opts.command, |
| + 'metric': metric, |
| + 'change': change, |
| + 'score': bisect_results.confidence, |
| + 'good_revision': opts.good_revision, |
| + 'bad_revision': opts.bad_revision, |
| + 'warnings': bisect_results.warnings, |
| + 'abort_reason': bisect_results.abort_reason, |
| + 'culprit_data': _culprit_data(bisect_results), |
| + 'revision_data': _revision_data(bisect_results, depot_registry) |
| + } |
| + |
| + |
| +def _culprit_data(bisect_results): |
| + if not bisect_results.culprit_revisions: |
| + return None |
| + cl, culprit_info, depot = bisect_results.culprit_revisions[0] |
| + commit_link = _GetViewVCLinkFromDepotAndHash(cl, depot) |
| + if commit_link: |
| + commit_link = '\nLink : %s' % commit_link |
| + else: |
| + commit_link = ('\Description:\n%s' % culprit_info['body']) |
| + |
| + return { |
| + 'subject': culprit_info['subject'], |
| + 'author': culprit_info['email'], |
| + 'email': culprit_info['email'], |
| + 'cl_date': culprit_info['date'], |
| + 'commit_info': commit_link, |
| + 'revisions_links': [], |
| + 'cl': cl |
| + } |
| + |
| + |
| +def _revision_data(bisect_results, depot_registry): |
|
qyearsley
2016/01/26 18:08:01
Method names here (in the chromium repo) are Camel
chrisphan
2016/02/10 02:23:38
Done.
|
| + revision_rows = [] |
| + for state in bisect_results.state.GetRevisionStates(): |
| + commit_position = source_control.GetCommitPosition( |
| + state.revision, depot_registry.GetDepotDir(state.depot)) |
| + revision_rows.append({ |
| + 'depot_name': state.depot, |
| + 'deps_revision': state.revision, |
| + 'commit_pos': commit_position, |
| + 'result': 'good' if state.passed else 'bad', |
| + }) |
| + return revision_rows |
| + |
| + |
| +def _GetViewVCLinkFromDepotAndHash(git_revision, depot): |
| + """Gets link to the repository browser.""" |
| + if depot and 'viewvc' in bisect_utils.DEPOT_DEPS_NAME[depot]: |
| + return bisect_utils.DEPOT_DEPS_NAME[depot]['viewvc'] + git_revision |
| + return '' |