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

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. 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 26 matching lines...) Expand all
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(CrashReport(crashed_version = '5',
174 signature = 'sig', 174 signature = 'sig',
175 platform = 'canary', 175 platform = 'canary',
176 stacktrace = Stacktrace([stack], stack), 176 stacktrace = Stacktrace([stack], stack),
177 regression_range = ('4', '5'))) 177 regression_range = ('4', '5'),
178 dependencies = None,
179 dependency_rolls = None))
178 expected_regression_deps_rolls = copy.deepcopy(dep_rolls) 180 expected_regression_deps_rolls = copy.deepcopy(dep_rolls)
179 181
180 # Regression of a dep added/deleted (old_revision/new_revision is None) can 182 # 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 183 # not be known for sure and this case rarely happens, so just filter them
182 # out. 184 # out.
183 del expected_regression_deps_rolls['src/dep'] 185 del expected_regression_deps_rolls['src/dep']
184 self.assertEqual(passed_in_regression_deps_rolls[0], 186 self.assertEqual(passed_in_regression_deps_rolls[0],
185 expected_regression_deps_rolls) 187 expected_regression_deps_rolls)
186 188
187 def testGetDepsInCrashStack(self): 189 def testGetDepsInCrashStack(self):
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 return [suspect1, suspect2] 507 return [suspect1, suspect2]
506 508
507 self.mock(changelist_classifier, 'FindSuspects', _MockFindSuspects) 509 self.mock(changelist_classifier, 'FindSuspects', _MockFindSuspects)
508 self.mock(chrome_dependency_fetcher.ChromeDependencyFetcher, 510 self.mock(chrome_dependency_fetcher.ChromeDependencyFetcher,
509 'GetDependencyRollsDict', 511 'GetDependencyRollsDict',
510 lambda *_: {'src/': DependencyRoll('src/', 'https://repo', '1', '2')}) 512 lambda *_: {'src/': DependencyRoll('src/', 'https://repo', '1', '2')})
511 self.mock(chrome_dependency_fetcher.ChromeDependencyFetcher, 513 self.mock(chrome_dependency_fetcher.ChromeDependencyFetcher,
512 'GetDependency', lambda *_: {}) 514 'GetDependency', lambda *_: {})
513 515
514 self.assertListEqual(self.changelist_classifier(DUMMY_REPORT), []) 516 self.assertListEqual(self.changelist_classifier(DUMMY_REPORT), [])
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698