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

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

Issue 2414523002: [Findit] Reorganizing findit_for_*.py (Closed)
Patch Set: Fixing call to ScheduleNewAnalysis in handlers/crash/crash_handler.py Created 4 years, 2 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 6
7 from common import chromium_deps
8 from common.blame import Blame
7 from common.blame import Region 9 from common.blame import Region
8 from common.blame import Blame
9 from common.change_log import ChangeLog 10 from common.change_log import ChangeLog
10 from common.dependency import Dependency 11 from common.dependency import Dependency
11 from common.dependency import DependencyRoll 12 from common.dependency import DependencyRoll
12 from common.git_repository import GitRepository 13 from common.git_repository import GitRepository
13 from crash import findit_for_crash 14 from crash import changelist_classifier
15 from crash.crash_report import CrashReport
16 from crash.results import MatchResult
14 from crash.stacktrace import StackFrame 17 from crash.stacktrace import StackFrame
15 from crash.stacktrace import CallStack 18 from crash.stacktrace import CallStack
16 from crash.stacktrace import Stacktrace 19 from crash.stacktrace import Stacktrace
17 from crash.results import MatchResult
18 from crash.test.crash_test_suite import CrashTestSuite 20 from crash.test.crash_test_suite import CrashTestSuite
19 21
20
21 DUMMY_CHANGELOG1 = ChangeLog.FromDict({ 22 DUMMY_CHANGELOG1 = ChangeLog.FromDict({
22 'author_name': 'r@chromium.org', 23 'author_name': 'r@chromium.org',
23 'message': 'dummy', 24 'message': 'dummy',
24 'committer_email': 'r@chromium.org', 25 'committer_email': 'r@chromium.org',
25 'commit_position': 175900, 26 'commit_position': 175900,
26 'author_email': 'r@chromium.org', 27 'author_email': 'r@chromium.org',
27 'touched_files': [ 28 'touched_files': [
28 { 29 {
29 'change_type': 'add', 30 'change_type': 'add',
30 'new_path': 'a.cc', 31 'new_path': 'a.cc',
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 'author_time': 'Thu Apr 1 21:24:43 2016', 86 'author_time': 'Thu Apr 1 21:24:43 2016',
86 'committer_time': 'Thu Apr 1 21:28:39 2016', 87 'committer_time': 'Thu Apr 1 21:28:39 2016',
87 'commit_url': 88 'commit_url':
88 'https://repo.test/+/3', 89 'https://repo.test/+/3',
89 'code_review_url': 'https://codereview.chromium.org/3281', 90 'code_review_url': 'https://codereview.chromium.org/3281',
90 'committer_name': 'example@chromium.org', 91 'committer_name': 'example@chromium.org',
91 'revision': '3', 92 'revision': '3',
92 'reverted_revision': None 93 'reverted_revision': None
93 }) 94 })
94 95
96 # TODO(wrengr): re crrev.com/2414523002: we need to have a specified
97 # revision_range (even if the versions therein are None), because
98 # ChangelistClassifier.__call__ will take it apart in order to call
99 # GetDEPSRollsDict; if it can't then it will immediately return the
100 # empty list of results, breaking many of the tests here. Of course,
101 # taking revision_range apart isn't actually required for the tests,
102 # since we mock GetDEPSRollsDict. So, really what we ought to do in the
103 # long run is redesign things so that GetDEPSRollsDict takes the
104 # CrashReport directly and pulls out the revision_range and platform
105 # itself; that way ChangelistClassifier.__call__ needn't worry about it,
106 # allowing us to clean up the tests here.
107 DUMMY_REPORT = CrashReport(None, None, None, Stacktrace(), (None, None))
95 108
96 class FinditForCrashTest(CrashTestSuite): 109 class ChangelistClassifierTest(CrashTestSuite):
97 110
98 def testGetDepsInCrashStack(self): 111 def testGetDepsInCrashStack(self):
99 crash_stack = CallStack(0) 112 crash_stack = CallStack(0)
100 crash_stack.extend([ 113 crash_stack.extend([
101 StackFrame(0, 'src/', 'func0', 'f0.cc', 'src/f0.cc', [1]), 114 StackFrame(0, 'src/', 'func0', 'f0.cc', 'src/f0.cc', [1]),
102 StackFrame(1, 'src/', 'func1', 'f1.cc', 'src/f1.cc', [2, 3]), 115 StackFrame(1, 'src/', 'func1', 'f1.cc', 'src/f1.cc', [2, 3]),
103 StackFrame(1, '', 'func2', 'f2.cc', 'src/f2.cc', [2, 3]), 116 StackFrame(1, '', 'func2', 'f2.cc', 'src/f2.cc', [2, 3]),
104 ]) 117 ])
105 crash_deps = {'src/': Dependency('src/', 'https://chromium_repo', '1'), 118 crash_deps = {'src/': Dependency('src/', 'https://chromium_repo', '1'),
106 'src/v8/': Dependency('src/v8/', 'https://v8_repo', '2')} 119 'src/v8/': Dependency('src/v8/', 'https://v8_repo', '2')}
107 120
108 expected_stack_deps = {'src/': crash_deps['src/']} 121 expected_stack_deps = {'src/': crash_deps['src/']}
109 122
110 self.assertEqual( 123 self.assertDictEqual(
111 findit_for_crash.GetDepsInCrashStack(crash_stack, crash_deps), 124 changelist_classifier.GetDepsInCrashStack(crash_stack, crash_deps),
112 expected_stack_deps) 125 expected_stack_deps)
113 126
114 def testGetChangeLogsForFilesGroupedByDeps(self): 127 def testGetChangeLogsForFilesGroupedByDeps(self):
115 regression_deps_rolls = { 128 regression_deps_rolls = {
116 'src/dep1': DependencyRoll('src/dep1', 'https://url_dep1', '7', '9'), 129 'src/dep1': DependencyRoll('src/dep1', 'https://url_dep1', '7', '9'),
117 'src/dep2': DependencyRoll('src/dep2', 'repo_url', '3', None), 130 'src/dep2': DependencyRoll('src/dep2', 'repo_url', '3', None),
118 'src/': DependencyRoll('src/', ('https://chromium.googlesource.com/' 131 'src/': DependencyRoll('src/', ('https://chromium.googlesource.com/'
119 'chromium/src.git'), '4', '5') 132 'chromium/src.git'), '4', '5')
120 } 133 }
121 134
122 stack_deps = { 135 stack_deps = {
123 'src/': Dependency('src/', 'https://url_src', 'rev1', 'DEPS'), 136 'src/': Dependency('src/', 'https://url_src', 'rev1', 'DEPS'),
124 'src/new': Dependency('src/new', 'https://new', 'rev2', 'DEPS'), 137 'src/new': Dependency('src/new', 'https://new', 'rev2', 'DEPS'),
125 } 138 }
126 139
127 def _MockGetChangeLogs(*_): 140 def _MockGetChangeLogs(*_):
128 return [DUMMY_CHANGELOG1, DUMMY_CHANGELOG2, DUMMY_CHANGELOG3] 141 return [DUMMY_CHANGELOG1, DUMMY_CHANGELOG2, DUMMY_CHANGELOG3]
129 142
130 self.mock(GitRepository, 'GetChangeLogs', _MockGetChangeLogs) 143 self.mock(GitRepository, 'GetChangeLogs', _MockGetChangeLogs)
131 144
132 dep_file_to_changelogs, ignore_cls = ( 145 dep_file_to_changelogs, ignore_cls = (
133 findit_for_crash.GetChangeLogsForFilesGroupedByDeps( 146 changelist_classifier.GetChangeLogsForFilesGroupedByDeps(
134 regression_deps_rolls, stack_deps)) 147 regression_deps_rolls, stack_deps))
135 dep_file_to_changelogs_json = defaultdict(lambda: defaultdict(list)) 148 dep_file_to_changelogs_json = defaultdict(lambda: defaultdict(list))
136 for dep, file_to_changelogs in dep_file_to_changelogs.iteritems(): 149 for dep, file_to_changelogs in dep_file_to_changelogs.iteritems():
137 for file_path, changelogs in file_to_changelogs.iteritems(): 150 for file_path, changelogs in file_to_changelogs.iteritems():
138 for changelog in changelogs: 151 for changelog in changelogs:
139 dep_file_to_changelogs_json[dep][file_path].append(changelog.ToDict()) 152 dep_file_to_changelogs_json[dep][file_path].append(changelog.ToDict())
140 153
141 expected_dep_file_to_changelogs_json = { 154 expected_dep_file_to_changelogs_json = {
142 'src/': { 155 'src/': {
143 'a.cc': [DUMMY_CHANGELOG1.ToDict()], 156 'a.cc': [DUMMY_CHANGELOG1.ToDict()],
144 'f.cc': [DUMMY_CHANGELOG3.ToDict()] 157 'f.cc': [DUMMY_CHANGELOG3.ToDict()]
145 } 158 }
146 } 159 }
147 self.assertEqual(dep_file_to_changelogs_json, 160 self.assertDictEqual(dep_file_to_changelogs_json,
148 expected_dep_file_to_changelogs_json) 161 expected_dep_file_to_changelogs_json)
149 self.assertEqual(ignore_cls, set(['1'])) 162 self.assertSetEqual(ignore_cls, set(['1']))
150 163
151 def testGetStackInfosForFilesGroupedByDeps(self): 164 def testGetStackInfosForFilesGroupedByDeps(self):
152
153 main_stack = CallStack(0) 165 main_stack = CallStack(0)
154 main_stack.extend( 166 main_stack.extend(
155 [StackFrame(0, 'src/', 'c(p* &d)', 'a.cc', 'src/a.cc', [177]), 167 [StackFrame(0, 'src/', 'c(p* &d)', 'a.cc', 'src/a.cc', [177]),
156 StackFrame(1, 'src/', 'd(a* c)', 'a.cc', 'src/a.cc', [227, 228, 229]), 168 StackFrame(1, 'src/', 'd(a* c)', 'a.cc', 'src/a.cc', [227, 228, 229]),
157 StackFrame(2, 'src/v8/', 'e(int)', 'b.cc', 'src/v8/b.cc', [89, 90])]) 169 StackFrame(2, 'src/v8/', 'e(int)', 'b.cc', 'src/v8/b.cc', [89, 90])])
158 170
159 low_priority_stack = CallStack(1) 171 low_priority_stack = CallStack(1)
160 low_priority_stack.append( 172 low_priority_stack.append(
161 StackFrame(0, 'src/dummy/', 'c(p* &d)', 'd.cc', 'src/dummy/d.cc', [17])) 173 StackFrame(0, 'src/dummy/', 'c(p* &d)', 'd.cc', 'src/dummy/d.cc', [17]))
162 174
(...skipping 11 matching lines...) Expand all
174 ], 186 ],
175 }, 187 },
176 'src/v8/': { 188 'src/v8/': {
177 'b.cc': [ 189 'b.cc': [
178 (main_stack[2], 0), 190 (main_stack[2], 0),
179 ] 191 ]
180 } 192 }
181 } 193 }
182 194
183 dep_file_to_stack_infos = ( 195 dep_file_to_stack_infos = (
184 findit_for_crash.GetStackInfosForFilesGroupedByDeps( 196 changelist_classifier.GetStackInfosForFilesGroupedByDeps(
185 stacktrace, crashed_deps)) 197 stacktrace, crashed_deps))
186 198
187 self.assertEqual(len(dep_file_to_stack_infos), 199 self.assertEqual(len(dep_file_to_stack_infos),
188 len(expected_dep_file_to_stack_infos)) 200 len(expected_dep_file_to_stack_infos))
189 201
190 for dep, file_to_stack_infos in dep_file_to_stack_infos.iteritems(): 202 for dep, file_to_stack_infos in dep_file_to_stack_infos.iteritems():
191 self.assertTrue(dep in expected_dep_file_to_stack_infos) 203 self.assertTrue(dep in expected_dep_file_to_stack_infos)
192 expected_file_to_stack_infos = expected_dep_file_to_stack_infos[dep] 204 expected_file_to_stack_infos = expected_dep_file_to_stack_infos[dep]
193 205
194 for file_path, stack_infos in file_to_stack_infos.iteritems(): 206 for file_path, stack_infos in file_to_stack_infos.iteritems():
(...skipping 22 matching lines...) Expand all
217 ] 229 ]
218 } 230 }
219 } 231 }
220 232
221 dummy_blame = Blame('9', 'a.cc') 233 dummy_blame = Blame('9', 'a.cc')
222 dummy_blame.AddRegion( 234 dummy_blame.AddRegion(
223 Region(1, 5, '6', 'a', 'a@chromium.org', 'Thu Mar 31 21:24:43 2016')) 235 Region(1, 5, '6', 'a', 'a@chromium.org', 'Thu Mar 31 21:24:43 2016'))
224 dummy_blame.AddRegion( 236 dummy_blame.AddRegion(
225 Region(6, 10, '1', 'b', 'b@chromium.org', 'Thu Jun 19 12:11:40 2015')) 237 Region(6, 10, '1', 'b', 'b@chromium.org', 'Thu Jun 19 12:11:40 2015'))
226 238
227 def _MockGetBlame(*_): 239 self.mock(GitRepository, 'GetBlame', lambda *_: dummy_blame)
228 return dummy_blame
229
230 self.mock(GitRepository, 'GetBlame', _MockGetBlame)
231 240
232 stack_deps = { 241 stack_deps = {
233 'src/': Dependency('src/', 'https://url_src', 'rev1', 'DEPS'), 242 'src/': Dependency('src/', 'https://url_src', 'rev1', 'DEPS'),
234 } 243 }
235 244
236 expected_match_results = [{ 245 expected_match_results = [{
237 'url': 'https://repo.test/+/1', 246 'url': 'https://repo.test/+/1',
238 'review_url': 'https://codereview.chromium.org/3281', 247 'review_url': 'https://codereview.chromium.org/3281',
239 'revision': '1', 248 'revision': '1',
240 'project_path': 'src/', 249 'project_path': 'src/',
241 'author': 'r@chromium.org', 250 'author': 'r@chromium.org',
242 'time': 'Thu Mar 31 21:24:43 2016', 251 'time': 'Thu Mar 31 21:24:43 2016',
243 'reasons': None, 252 'reasons': None,
244 'confidence': None, 253 'confidence': None,
245 'changed_files': None 254 'changed_files': None
246 }] 255 }]
247 256
248 match_results = findit_for_crash.FindMatchResults( 257 match_results = changelist_classifier.FindMatchResults(
249 dep_file_to_changelogs, dep_file_to_stack_infos, stack_deps) 258 dep_file_to_changelogs, dep_file_to_stack_infos, stack_deps)
250 self.assertEqual([result.ToDict() for result in match_results], 259 self.assertListEqual([result.ToDict() for result in match_results],
251 expected_match_results) 260 expected_match_results)
252 261
253 def testFindItForCrashNoRegressionRange(self): 262 def testFindItForCrashNoRegressionRange(self):
254 self.assertEqual( 263 self.mock(chromium_deps, 'GetDEPSRollsDict', lambda *_: {})
255 findit_for_crash.FindItForCrash(Stacktrace(), {}, {}, 7), 264 self.mock(chromium_deps, 'GetChromeDependency', lambda *_: {})
256 []) 265 # N.B., for this one test we really do want regression_range=None.
266 report = DUMMY_REPORT._replace(regression_range=None)
267 self.assertListEqual(
268 changelist_classifier.ChangelistClassifier(7)(report), [])
257 269
258 def testFindItForCrashNoMatchFound(self): 270 def testFindItForCrashNoMatchFound(self):
259 271 self.mock(changelist_classifier, 'FindMatchResults', lambda *_: [])
260 def _MockFindMatchResults(*_): 272 self.mock(chromium_deps, 'GetDEPSRollsDict', lambda *_:
261 return [] 273 {'src/': DependencyRoll('src/', 'https://repo', '1', '2')})
262 274 self.mock(chromium_deps, 'GetChromeDependency', lambda *_: {})
263 self.mock(findit_for_crash, 'FindMatchResults', _MockFindMatchResults) 275 self.assertListEqual(
264 276 changelist_classifier.ChangelistClassifier(7)(DUMMY_REPORT), [])
265 regression_deps_rolls = {'src/': DependencyRoll('src/', 'https://repo',
266 '1', '2')}
267 self.assertEqual(findit_for_crash.FindItForCrash(
268 Stacktrace(), regression_deps_rolls, {}, 7), [])
269 277
270 def testFindItForCrash(self): 278 def testFindItForCrash(self):
271 279
272 def _MockFindMatchResults(*_): 280 def _MockFindMatchResults(*_):
273 match_result1 = MatchResult(DUMMY_CHANGELOG1, 'src/', '') 281 match_result1 = MatchResult(DUMMY_CHANGELOG1, 'src/', '')
274 frame1 = StackFrame(0, 'src/', 'func', 'a.cc', 'src/a.cc', [1]) 282 frame1 = StackFrame(0, 'src/', 'func', 'a.cc', 'src/a.cc', [1])
275 frame2 = StackFrame(1, 'src/', 'func', 'a.cc', 'src/a.cc', [7]) 283 frame2 = StackFrame(1, 'src/', 'func', 'a.cc', 'src/a.cc', [7])
276 match_result1.file_to_stack_infos = { 284 match_result1.file_to_stack_infos = {
277 'a.cc': [(frame1, 0), (frame2, 0)] 285 'a.cc': [(frame1, 0), (frame2, 0)]
278 } 286 }
279 match_result1.file_to_analysis_info = { 287 match_result1.file_to_analysis_info = {
280 'a.cc': {'min_distance': 0, 'min_distance_frame': frame1} 288 'a.cc': {'min_distance': 0, 'min_distance_frame': frame1}
281 } 289 }
282 290
283 match_result2 = MatchResult(DUMMY_CHANGELOG3, 'src/', '') 291 match_result2 = MatchResult(DUMMY_CHANGELOG3, 'src/', '')
284 frame3 = StackFrame(5, 'src/', 'func', 'f.cc', 'src/f.cc', [1]) 292 frame3 = StackFrame(5, 'src/', 'func', 'f.cc', 'src/f.cc', [1])
285 match_result2.file_to_stack_infos = { 293 match_result2.file_to_stack_infos = {
286 'f.cc': [(frame3, 0)] 294 'f.cc': [(frame3, 0)]
287 } 295 }
288 match_result2.file_to_analysis_info = { 296 match_result2.file_to_analysis_info = {
289 'a.cc': {'min_distance': 20, 'min_distance_frame': frame3} 297 'a.cc': {'min_distance': 20, 'min_distance_frame': frame3}
290 } 298 }
291 299
292 return [match_result1, match_result2] 300 return [match_result1, match_result2]
293 301
294 self.mock(findit_for_crash, 'FindMatchResults', _MockFindMatchResults) 302 self.mock(changelist_classifier, 'FindMatchResults', _MockFindMatchResults)
295 303 self.mock(chromium_deps, 'GetDEPSRollsDict', lambda *_:
304 {'src/': DependencyRoll('src/', 'https://repo', '1', '2')})
305 self.mock(chromium_deps, 'GetChromeDependency', lambda *_: {})
306 results = changelist_classifier.ChangelistClassifier(7)(DUMMY_REPORT)
296 expected_match_results = [ 307 expected_match_results = [
297 { 308 {
298 'reasons': [('TopFrameIndex', 1.0, 'Top frame is #0'), 309 'reasons': [('TopFrameIndex', 1.0, 'Top frame is #0'),
299 ('MinDistance', 1, 'Minimum distance is 0')], 310 ('MinDistance', 1, 'Minimum distance is 0')],
300 'changed_files': [{'info': 'Minimum distance (LOC) 0, frame #0', 311 'changed_files': [{'info': 'Minimum distance (LOC) 0, frame #0',
301 'blame_url': None, 'file': 'a.cc'}], 312 'blame_url': None, 'file': 'a.cc'}],
302 'time': 'Thu Mar 31 21:24:43 2016', 313 'time': 'Thu Mar 31 21:24:43 2016',
303 'author': 'r@chromium.org', 314 'author': 'r@chromium.org',
304 'url': 'https://repo.test/+/1', 315 'url': 'https://repo.test/+/1',
305 'project_path': 'src/', 316 'project_path': 'src/',
306 'review_url': 'https://codereview.chromium.org/3281', 317 'review_url': 'https://codereview.chromium.org/3281',
307 'confidence': 1.0, 'revision': '1' 318 'confidence': 1.0, 'revision': '1'
308 }, 319 },
309 ] 320 ]
310 321 self.assertListEqual([result.ToDict() for result in results],
311 regression_deps_rolls = {'src/': DependencyRoll('src/', 'https://repo', 322 expected_match_results)
312 '1', '2')}
313
314 results = findit_for_crash.FindItForCrash(Stacktrace(),
315 regression_deps_rolls, {}, 7)
316 self.assertEqual([result.ToDict() for result in results],
317 expected_match_results)
318 323
319 def testFinditForCrashFilterZeroConfidentResults(self): 324 def testFinditForCrashFilterZeroConfidentResults(self):
320 def _MockFindMatchResults(*_): 325 def _MockFindMatchResults(*_):
321 match_result1 = MatchResult(DUMMY_CHANGELOG1, 'src/', '') 326 match_result1 = MatchResult(DUMMY_CHANGELOG1, 'src/', '')
322 frame1 = StackFrame(0, 'src/', 'func', 'a.cc', 'src/a.cc', [1]) 327 frame1 = StackFrame(0, 'src/', 'func', 'a.cc', 'src/a.cc', [1])
323 frame2 = StackFrame(1, 'src/', 'func', 'a.cc', 'src/a.cc', [7]) 328 frame2 = StackFrame(1, 'src/', 'func', 'a.cc', 'src/a.cc', [7])
324 match_result1.file_to_stack_infos = { 329 match_result1.file_to_stack_infos = {
325 'a.cc': [(frame1, 0), (frame2, 0)] 330 'a.cc': [(frame1, 0), (frame2, 0)]
326 } 331 }
327 match_result1.file_to_analysis_info = { 332 match_result1.file_to_analysis_info = {
(...skipping 13 matching lines...) Expand all
341 frame4 = StackFrame(3, 'src/', 'func', 'ff.cc', 'src/ff.cc', [1]) 346 frame4 = StackFrame(3, 'src/', 'func', 'ff.cc', 'src/ff.cc', [1])
342 match_result3.file_to_stack_infos = { 347 match_result3.file_to_stack_infos = {
343 'f.cc': [(frame4, 0)] 348 'f.cc': [(frame4, 0)]
344 } 349 }
345 match_result3.file_to_analysis_info = { 350 match_result3.file_to_analysis_info = {
346 'f.cc': {'min_distance': 60, 'min_distance_frame': frame4} 351 'f.cc': {'min_distance': 60, 'min_distance_frame': frame4}
347 } 352 }
348 353
349 return [match_result1, match_result2, match_result3] 354 return [match_result1, match_result2, match_result3]
350 355
351 self.mock(findit_for_crash, 'FindMatchResults', _MockFindMatchResults) 356 self.mock(changelist_classifier, 'FindMatchResults', _MockFindMatchResults)
357 self.mock(chromium_deps, 'GetDEPSRollsDict', lambda *_:
358 {'src/': DependencyRoll('src/', 'https://repo', '1', '2')})
359 self.mock(chromium_deps, 'GetChromeDependency', lambda *_: {})
352 360
361 results = changelist_classifier.ChangelistClassifier(7)(DUMMY_REPORT)
353 expected_match_results = [ 362 expected_match_results = [
354 { 363 {
355 'author': 'r@chromium.org', 364 'author': 'r@chromium.org',
356 'changed_files': [ 365 'changed_files': [
357 { 366 {
358 'blame_url': None, 367 'blame_url': None,
359 'file': 'a.cc', 368 'file': 'a.cc',
360 'info': 'Minimum distance (LOC) 1, frame #0' 369 'info': 'Minimum distance (LOC) 1, frame #0'
361 } 370 }
362 ], 371 ],
363 'confidence': 0.8, 372 'confidence': 0.8,
364 'project_path': 'src/', 373 'project_path': 'src/',
365 'reasons': [ 374 'reasons': [
366 ('TopFrameIndex', 1.0, 'Top frame is #0'), 375 ('TopFrameIndex', 1.0, 'Top frame is #0'),
367 ('MinDistance', 0.8, 'Minimum distance is 1') 376 ('MinDistance', 0.8, 'Minimum distance is 1')
368 ], 377 ],
369 'review_url': 'https://codereview.chromium.org/3281', 378 'review_url': 'https://codereview.chromium.org/3281',
370 'revision': '1', 379 'revision': '1',
371 'time': 'Thu Mar 31 21:24:43 2016', 380 'time': 'Thu Mar 31 21:24:43 2016',
372 'url': 'https://repo.test/+/1' 381 'url': 'https://repo.test/+/1'
373 } 382 }
374 ] 383 ]
375 384 self.assertListEqual([result.ToDict() for result in results],
376 regression_deps_rolls = {'src/': DependencyRoll('src/', 'https://repo', 385 expected_match_results)
377 '1', '2')}
378
379 results = findit_for_crash.FindItForCrash(Stacktrace(),
380 regression_deps_rolls, {}, 7)
381
382 self.assertEqual([result.ToDict() for result in results],
383 expected_match_results)
384 386
385 def testFinditForCrashAllMatchResultsWithZeroConfidences(self): 387 def testFinditForCrashAllMatchResultsWithZeroConfidences(self):
386 def _MockFindMatchResults(*_): 388 def _MockFindMatchResults(*_):
387 match_result1 = MatchResult(DUMMY_CHANGELOG1, 'src/', '') 389 match_result1 = MatchResult(DUMMY_CHANGELOG1, 'src/', '')
388 frame1 = StackFrame(20, 'src/', '', 'func', 'a.cc', [1]) 390 frame1 = StackFrame(20, 'src/', '', 'func', 'a.cc', [1])
389 frame2 = StackFrame(21, 'src/', '', 'func', 'a.cc', [7]) 391 frame2 = StackFrame(21, 'src/', '', 'func', 'a.cc', [7])
390 match_result1.file_to_stack_infos = { 392 match_result1.file_to_stack_infos = {
391 'a.cc': [(frame1, 0), (frame2, 0)] 393 'a.cc': [(frame1, 0), (frame2, 0)]
392 } 394 }
393 match_result1.file_to_analysis_info = { 395 match_result1.file_to_analysis_info = {
394 'a.cc': {'min_distance': 1, 'min_distance_frame': frame1} 396 'a.cc': {'min_distance': 1, 'min_distance_frame': frame1}
395 } 397 }
396 398
397 match_result2 = MatchResult(DUMMY_CHANGELOG3, 'src/', '') 399 match_result2 = MatchResult(DUMMY_CHANGELOG3, 'src/', '')
398 frame3 = StackFrame(15, 'src/', '', 'func', 'f.cc', [1]) 400 frame3 = StackFrame(15, 'src/', '', 'func', 'f.cc', [1])
399 match_result2.file_to_stack_infos = { 401 match_result2.file_to_stack_infos = {
400 'f.cc': [(frame3, 0)] 402 'f.cc': [(frame3, 0)]
401 } 403 }
402 match_result2.min_distance = 20 404 match_result2.min_distance = 20
403 match_result2.file_to_analysis_info = { 405 match_result2.file_to_analysis_info = {
404 'f.cc': {'min_distance': 20, 'min_distance_frame': frame3} 406 'f.cc': {'min_distance': 20, 'min_distance_frame': frame3}
405 } 407 }
406 408
407 return [match_result1, match_result2] 409 return [match_result1, match_result2]
408 410
409 self.mock(findit_for_crash, 'FindMatchResults', _MockFindMatchResults) 411 self.mock(changelist_classifier, 'FindMatchResults', _MockFindMatchResults)
412 self.mock(chromium_deps, 'GetDEPSRollsDict', lambda *_:
413 {'src/': DependencyRoll('src/', 'https://repo', '1', '2')})
414 self.mock(chromium_deps, 'GetChromeDependency', lambda *_: {})
410 415
411 regression_deps_rolls = {'src/': DependencyRoll('src/', 'https://repo', 416 self.assertListEqual(
412 '1', '2')} 417 changelist_classifier.ChangelistClassifier(7)(DUMMY_REPORT), [])
413
414 self.assertEqual(findit_for_crash.FindItForCrash(
415 Stacktrace(), regression_deps_rolls, {}, 7), [])
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698