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 import logging | 5 import logging |
6 | 6 |
7 from google.appengine.ext import ndb | 7 from google.appengine.ext import ndb |
8 | 8 |
9 from common import appengine_util | 9 from common import appengine_util |
10 from crash import detect_regression_range | 10 from crash import detect_regression_range |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 logging.warning('FinditForChromeCrash is abstract, ' | 42 logging.warning('FinditForChromeCrash is abstract, ' |
43 'but someone constructed an instance and called _ClientID') | 43 'but someone constructed an instance and called _ClientID') |
44 else: | 44 else: |
45 logging.warning( | 45 logging.warning( |
46 'FinditForChromeCrash subclass %s forgot to implement _ClientID', | 46 'FinditForChromeCrash subclass %s forgot to implement _ClientID', |
47 cls.__name__) | 47 cls.__name__) |
48 raise NotImplementedError() | 48 raise NotImplementedError() |
49 | 49 |
50 # TODO(http://crbug.com/659354): remove the dependency on CrashConfig | 50 # TODO(http://crbug.com/659354): remove the dependency on CrashConfig |
51 # entirely, by passing the relevant data as arguments to this constructor. | 51 # entirely, by passing the relevant data as arguments to this constructor. |
52 def __init__(self, repository): | 52 def __init__(self, get_repository): |
53 super(FinditForChromeCrash, self).__init__(repository) | 53 super(FinditForChromeCrash, self).__init__(get_repository) |
54 component_classifier_config = CrashConfig.Get().component_classifier | 54 component_classifier_config = CrashConfig.Get().component_classifier |
55 | 55 |
56 self._stacktrace_parser = ChromeCrashParser() | 56 self._stacktrace_parser = ChromeCrashParser() |
57 | 57 |
58 # TODO(crbug.com/677224): should replace this with an actual factory. | |
59 def MutateTheRepo(dep_url): # pragma: no cover | |
60 """A factory function for returning ``Repository`` objects. | |
61 | |
62 The current definition captures the functionality of before | |
63 we factored out this factory method. That is, it's not really a | |
64 "factory" but rather mutates the main repo object in place. In | |
65 the future this should be changed to do the right thing instead. | |
66 """ | |
67 repository.repo_url = dep_url | |
68 return repository | |
69 | |
70 # The top_n is the number of components we should return as | 58 # The top_n is the number of components we should return as |
71 # components suggestion results. | 59 # components suggestion results. |
72 self._predator = Predator( | 60 self._predator = Predator( |
73 cl_classifier = ChangelistClassifier(repository, MutateTheRepo), | 61 cl_classifier = ChangelistClassifier(get_repository), |
74 component_classifier = ComponentClassifier( | 62 component_classifier = ComponentClassifier( |
75 [Component(component_name, path_regex, function_regex) | 63 [Component(component_name, path_regex, function_regex) |
76 for path_regex, function_regex, component_name | 64 for path_regex, function_regex, component_name |
77 in component_classifier_config['path_function_component']], | 65 in component_classifier_config['path_function_component']], |
78 component_classifier_config['top_n']), | 66 component_classifier_config['top_n']), |
79 project_classifier = ProjectClassifier()) | 67 project_classifier = ProjectClassifier()) |
80 | 68 |
81 def _InitializeAnalysis(self, model, crash_data): | 69 def _InitializeAnalysis(self, model, crash_data): |
82 super(FinditForChromeCrash, self)._InitializeAnalysis(model, crash_data) | 70 super(FinditForChromeCrash, self)._InitializeAnalysis(model, crash_data) |
83 # TODO(wrengr): see Note#1 | 71 # TODO(wrengr): see Note#1 |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 | 167 |
180 def GetAnalysis(self, crash_identifiers): | 168 def GetAnalysis(self, crash_identifiers): |
181 # TODO: inline FracasCrashAnalysis.Get stuff here. | 169 # TODO: inline FracasCrashAnalysis.Get stuff here. |
182 return FracasCrashAnalysis.Get(crash_identifiers) | 170 return FracasCrashAnalysis.Get(crash_identifiers) |
183 | 171 |
184 def ProcessResultForPublishing(self, result, key): | 172 def ProcessResultForPublishing(self, result, key): |
185 """Fracas specific processing of result data for publishing.""" | 173 """Fracas specific processing of result data for publishing.""" |
186 result['feedback_url'] = _FRACAS_FEEDBACK_URL_TEMPLATE % ( | 174 result['feedback_url'] = _FRACAS_FEEDBACK_URL_TEMPLATE % ( |
187 appengine_util.GetDefaultVersionHostname(), key) | 175 appengine_util.GetDefaultVersionHostname(), key) |
188 return result | 176 return result |
OLD | NEW |