Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 from collections import namedtuple | 5 from collections import namedtuple |
| 6 | 6 |
| 7 # TODO(http://crbug.com/659346): We do call this code from various | 7 |
| 8 # unittests, just not from culprit_test.py; so we need to add some extra | |
| 9 # unittests there. | |
| 10 class Culprit(namedtuple('Culprit', | 8 class Culprit(namedtuple('Culprit', |
| 11 ['project', 'components', 'cls', 'regression_range', 'algorithm'] | 9 ['project', 'components', 'cls', 'regression_range', 'algorithm'])): |
| 12 )): # pragma: no cover | |
| 13 """The result of successfully identifying the culprit of a crash report. | 10 """The result of successfully identifying the culprit of a crash report. |
| 14 | 11 |
| 15 Args: | 12 Args: |
| 16 project (str): the most-suspected project | 13 project (str): the most-suspected project |
| 17 components (list of str): the suspected crbug components. | 14 components (list of str): the suspected crbug components. |
| 18 cls (list of ??): the suspected CLs. | 15 cls (list of ??): the suspected CLs. |
| 19 regression_range (tuple): a pair of the last-good and first-bad versions. | 16 regression_range (tuple): a pair of the last-good and first-bad versions. |
| 20 algorithm (str): What algorithm was used to produce this object. | 17 algorithm (str): What algorithm was used to produce this object. |
| 21 """ | 18 """ |
| 22 __slots__ = () | 19 __slots__ = () |
| 23 | 20 |
| 24 @property | 21 @property |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 94 """ | 91 """ |
| 95 # TODO(wrengr): will this auto-dropping of unnecessary fields cause | 92 # TODO(wrengr): will this auto-dropping of unnecessary fields cause |
| 96 # any issues for JSON serialization? | 93 # any issues for JSON serialization? |
| 97 result = {} | 94 result = {} |
| 98 result['found'] = ( | 95 result['found'] = ( |
| 99 bool(self.project) or | 96 bool(self.project) or |
| 100 bool(self.components) or | 97 bool(self.components) or |
| 101 bool(self.cls) or | 98 bool(self.cls) or |
| 102 bool(self.regression_range)) | 99 bool(self.regression_range)) |
| 103 if self.regression_range: | 100 if self.regression_range: |
| 104 result['regression_range'] = self.regression_range | 101 result['regression_range'] = self.regression_range |
|
wrengr
2016/10/31 23:48:35
self.regression_range stores a tuple; however, JSO
Sharu Jiang
2016/11/01 23:54:09
Done.
| |
| 105 if self.project is not None: | 102 if self.project is not None: |
|
Sharu Jiang
2016/11/01 23:54:09
Since the project_classifier can return '' and com
| |
| 106 result['suspected_project'] = self.project | 103 result['suspected_project'] = self.project |
| 107 if self.components is not None: | 104 if self.components is not None: |
| 108 result['suspected_components'] = self.components | 105 result['suspected_components'] = self.components |
| 109 if self.cls is not None: | 106 if self.cls is not None: |
| 110 result['suspected_cls'] = [cl.ToDict() for cl in self.cls] | 107 result['suspected_cls'] = [cl.ToDict() for cl in self.cls] |
| 111 | 108 |
| 112 tags = { | 109 tags = { |
| 113 'found_suspects': bool(self.cls), | 110 'found_suspects': bool(self.cls), |
| 114 'has_regression_range': bool(self.regression_range), | 111 'has_regression_range': bool(self.regression_range), |
| 115 'found_project': bool(self.project), | 112 'found_project': bool(self.project), |
| 116 'found_components': bool(self.components), | 113 'found_components': bool(self.components), |
| 117 'solution': self.algorithm, | 114 'solution': self.algorithm, |
| 118 } | 115 } |
| 119 | 116 |
| 120 return result, tags | 117 return result, tags |
| OLD | NEW |