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

Side by Side Diff: appengine/findit/crash/test/changelist_classifier_test.py

Issue 2663063007: [Predator] Switch from anonymous dict to CrashData. (Closed)
Patch Set: Rebase and fix delta test. Created 3 years, 10 months 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 unified diff | Download patch
OLDNEW
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 defaultdict 5 from collections import defaultdict
6 import copy 6 import copy
7 7
8 from common.dependency import Dependency 8 from common.dependency import Dependency
9 from common.dependency import DependencyRoll 9 from common.dependency import DependencyRoll
10 from common import chrome_dependency_fetcher 10 from common import chrome_dependency_fetcher
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 # since we mock GetDEPSRollsDict. So, really what we ought to do in the 119 # since we mock GetDEPSRollsDict. So, really what we ought to do in the
120 # long run is redesign things so that GetDEPSRollsDict takes the 120 # long run is redesign things so that GetDEPSRollsDict takes the
121 # CrashReport directly and pulls out the revision_range and platform 121 # CrashReport directly and pulls out the revision_range and platform
122 # itself; that way ChangelistClassifier.__call__ needn't worry about it, 122 # itself; that way ChangelistClassifier.__call__ needn't worry about it,
123 # allowing us to clean up the tests here. 123 # allowing us to clean up the tests here.
124 124
125 DUMMY_CALLSTACKS = [ 125 DUMMY_CALLSTACKS = [
126 CallStack(0, [], CallStackFormatType.DEFAULT, LanguageType.CPP), 126 CallStack(0, [], CallStackFormatType.DEFAULT, LanguageType.CPP),
127 CallStack(1, [], CallStackFormatType.DEFAULT, LanguageType.CPP)] 127 CallStack(1, [], CallStackFormatType.DEFAULT, LanguageType.CPP)]
128 DUMMY_REPORT = CrashReport( 128 DUMMY_REPORT = CrashReport(
129 None, None, None, Stacktrace(DUMMY_CALLSTACKS, DUMMY_CALLSTACKS[0]), 129 'rev', 'sig', 'win', Stacktrace(DUMMY_CALLSTACKS, DUMMY_CALLSTACKS[0]),
130 (None, None)) 130 (None, None), None, None)
131 131
132 132
133 class ChangelistClassifierTest(CrashTestSuite): 133 class ChangelistClassifierTest(CrashTestSuite):
134 134
135 @property 135 @property
136 def _mock_http_gitiles_repo_factory(self): 136 def _mock_http_gitiles_repo_factory(self):
137 # N.B., we must return a lambda rather than taking ``repo_url`` 137 # N.B., we must return a lambda rather than taking ``repo_url``
138 # as an additional argument to the method/property, to ensure that 138 # as an additional argument to the method/property, to ensure that
139 # things have the right arity when this is eventually called. That 139 # things have the right arity when this is eventually called. That
140 # is, we want a function of ``repo_url`` which closes over ``self``, 140 # is, we want a function of ``repo_url`` which closes over ``self``,
(...skipping 22 matching lines...) Expand all
163 passed_in_regression_deps_rolls.append(regression_deps_rolls) 163 passed_in_regression_deps_rolls.append(regression_deps_rolls)
164 return {}, None 164 return {}, None
165 165
166 self.mock(changelist_classifier, 'GetChangeLogsForFilesGroupedByDeps', 166 self.mock(changelist_classifier, 'GetChangeLogsForFilesGroupedByDeps',
167 _MockGetChangeLogsForFilesGroupedByDeps) 167 _MockGetChangeLogsForFilesGroupedByDeps)
168 self.mock(changelist_classifier, 'GetStackInfosForFilesGroupedByDeps', 168 self.mock(changelist_classifier, 'GetStackInfosForFilesGroupedByDeps',
169 lambda *_: {}) 169 lambda *_: {})
170 self.mock(changelist_classifier, 'FindSuspects', lambda *_: None) 170 self.mock(changelist_classifier, 'FindSuspects', lambda *_: None)
171 171
172 stack = CallStack(0) 172 stack = CallStack(0)
173 self.changelist_classifier(CrashReport(crashed_version = '5', 173 self.changelist_classifier(
174 signature = 'sig', 174 CrashReport(crashed_version = '5',
175 platform = 'canary', 175 signature = 'sig',
176 stacktrace = Stacktrace([stack], stack), 176 platform = 'canary',
177 regression_range = ('4', '5'))) 177 stacktrace = Stacktrace([stack], stack),
178 regression_range = ('4', '5'),
179 dependencies = {},
180 dependency_rolls = {}))
178 expected_regression_deps_rolls = copy.deepcopy(dep_rolls) 181 expected_regression_deps_rolls = copy.deepcopy(dep_rolls)
179 182
180 # Regression of a dep added/deleted (old_revision/new_revision is None) can 183 # Regression of a dep added/deleted (old_revision/new_revision is None) can
181 # not be known for sure and this case rarely happens, so just filter them 184 # not be known for sure and this case rarely happens, so just filter them
182 # out. 185 # out.
183 del expected_regression_deps_rolls['src/dep'] 186 del expected_regression_deps_rolls['src/dep']
184 self.assertEqual(passed_in_regression_deps_rolls[0], 187 self.assertEqual(passed_in_regression_deps_rolls[0],
185 expected_regression_deps_rolls) 188 expected_regression_deps_rolls)
186 189
187 def testGetDepsInCrashStack(self): 190 def testGetDepsInCrashStack(self):
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 return [suspect1, suspect2] 508 return [suspect1, suspect2]
506 509
507 self.mock(changelist_classifier, 'FindSuspects', _MockFindSuspects) 510 self.mock(changelist_classifier, 'FindSuspects', _MockFindSuspects)
508 self.mock(chrome_dependency_fetcher.ChromeDependencyFetcher, 511 self.mock(chrome_dependency_fetcher.ChromeDependencyFetcher,
509 'GetDependencyRollsDict', 512 'GetDependencyRollsDict',
510 lambda *_: {'src/': DependencyRoll('src/', 'https://repo', '1', '2')}) 513 lambda *_: {'src/': DependencyRoll('src/', 'https://repo', '1', '2')})
511 self.mock(chrome_dependency_fetcher.ChromeDependencyFetcher, 514 self.mock(chrome_dependency_fetcher.ChromeDependencyFetcher,
512 'GetDependency', lambda *_: {}) 515 'GetDependency', lambda *_: {})
513 516
514 self.assertListEqual(self.changelist_classifier(DUMMY_REPORT), []) 517 self.assertListEqual(self.changelist_classifier(DUMMY_REPORT), [])
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698