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

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

Issue 2075153003: [Findit] Add fracas analysis result feedback page. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Fix nits. Created 4 years, 6 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.blame import Region, Blame 7 from common.blame import Region, Blame
8 from common.change_log import ChangeLog 8 from common.change_log import ChangeLog
9 from common.dependency import Dependency, DependencyRoll 9 from common.dependency import Dependency, DependencyRoll
10 from common.git_repository import GitRepository 10 from common.git_repository import GitRepository
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 'url': 'https://repo.test/+/1', 304 'url': 'https://repo.test/+/1',
305 'project_path': 'src/', 305 'project_path': 'src/',
306 'review_url': 'https://codereview.chromium.org/3281', 306 'review_url': 'https://codereview.chromium.org/3281',
307 'confidence': 1.0, 'revision': '1' 307 'confidence': 1.0, 'revision': '1'
308 }, 308 },
309 ] 309 ]
310 310
311 regression_deps_rolls = {'src/': DependencyRoll('src/', 'https://repo', 311 regression_deps_rolls = {'src/': DependencyRoll('src/', 'https://repo',
312 '1', '2')} 312 '1', '2')}
313 313
314 self.assertEqual(findit_for_crash.FindItForCrash( 314 results = findit_for_crash.FindItForCrash(Stacktrace(),
315 Stacktrace(), regression_deps_rolls, {}), expected_match_results) 315 regression_deps_rolls, {})
316 self.assertEqual([result.ToDict() for result in results],
317 expected_match_results)
316 318
317 def testFinditForCrashFilterZeroConfidentResults(self): 319 def testFinditForCrashFilterZeroConfidentResults(self):
318 def _MockFindMatchResults(*_): 320 def _MockFindMatchResults(*_):
319 match_result1 = MatchResult(DUMMY_CHANGELOG1, 'src/', '') 321 match_result1 = MatchResult(DUMMY_CHANGELOG1, 'src/', '')
320 match_result1.file_to_stack_infos = { 322 match_result1.file_to_stack_infos = {
321 'a.cc': [ 323 'a.cc': [
322 (StackFrame(0, 'src/', 'func', 'a.cc', 'src/a.cc', [1]), 0), 324 (StackFrame(0, 'src/', 'func', 'a.cc', 'src/a.cc', [1]), 0),
323 (StackFrame(1, 'src/', 'func', 'a.cc', 'src/a.cc', [7]), 0), 325 (StackFrame(1, 'src/', 'func', 'a.cc', 'src/a.cc', [7]), 0),
324 ] 326 ]
325 } 327 }
(...skipping 22 matching lines...) Expand all
348 expected_match_results = [ 350 expected_match_results = [
349 { 351 {
350 'reason': ('(1) Modified top crashing frame is #0\n' 352 'reason': ('(1) Modified top crashing frame is #0\n'
351 '(2) Modification distance (LOC) is 1\n\n' 353 '(2) Modification distance (LOC) is 1\n\n'
352 'Changed file a.cc crashed in frame #0, frame #1'), 354 'Changed file a.cc crashed in frame #0, frame #1'),
353 'time': 'Thu Mar 31 21:24:43 2016', 355 'time': 'Thu Mar 31 21:24:43 2016',
354 'author': 'r@chromium.org', 356 'author': 'r@chromium.org',
355 'url': 'https://repo.test/+/1', 357 'url': 'https://repo.test/+/1',
356 'project_path': 'src/', 358 'project_path': 'src/',
357 'review_url': 'https://codereview.chromium.org/3281', 359 'review_url': 'https://codereview.chromium.org/3281',
358 'confidence': 0.8, 'revision': '1'}, 360 'confidence': 0.8, 'revision': '1'
361 },
359 ] 362 ]
360 363
361 regression_deps_rolls = {'src/': DependencyRoll('src/', 'https://repo', 364 regression_deps_rolls = {'src/': DependencyRoll('src/', 'https://repo',
362 '1', '2')} 365 '1', '2')}
363 366
364 self.assertEqual(findit_for_crash.FindItForCrash( 367 results = findit_for_crash.FindItForCrash(Stacktrace(),
365 Stacktrace(), regression_deps_rolls, {}), expected_match_results) 368 regression_deps_rolls, {})
369 self.assertEqual([result.ToDict() for result in results],
370 expected_match_results)
366 371
367 def testFinditForCrashAllMatchResultsWithZeroConfidences(self): 372 def testFinditForCrashAllMatchResultsWithZeroConfidences(self):
368 def _MockFindMatchResults(*_): 373 def _MockFindMatchResults(*_):
369 match_result1 = MatchResult(DUMMY_CHANGELOG1, 'src/', '') 374 match_result1 = MatchResult(DUMMY_CHANGELOG1, 'src/', '')
370 match_result1.file_to_stack_infos = { 375 match_result1.file_to_stack_infos = {
371 'a.cc': [ 376 'a.cc': [
372 (StackFrame(20, 'src/', '', 'func', 'a.cc', [1]), 0), 377 (StackFrame(20, 'src/', '', 'func', 'a.cc', [1]), 0),
373 (StackFrame(21, 'src/', '', 'func', 'a.cc', [7]), 0), 378 (StackFrame(21, 'src/', '', 'func', 'a.cc', [7]), 0),
374 ] 379 ]
375 } 380 }
376 match_result1.min_distance = 1 381 match_result1.min_distance = 1
377 382
378 match_result2 = MatchResult(DUMMY_CHANGELOG3, 'src/', '') 383 match_result2 = MatchResult(DUMMY_CHANGELOG3, 'src/', '')
379 match_result2.file_to_stack_infos = { 384 match_result2.file_to_stack_infos = {
380 'f.cc': [ 385 'f.cc': [
381 (StackFrame(15, 'src/', '', 'func', 'f.cc', [1]), 0), 386 (StackFrame(15, 'src/', '', 'func', 'f.cc', [1]), 0),
382 ] 387 ]
383 } 388 }
384 match_result2.min_distance = 20 389 match_result2.min_distance = 20
385 390
386 return [match_result1, match_result2], {} 391 return [match_result1, match_result2], {}
387 392
388 self.mock(findit_for_crash, 'FindMatchResults', _MockFindMatchResults) 393 self.mock(findit_for_crash, 'FindMatchResults', _MockFindMatchResults)
389 394
390 regression_deps_rolls = {'src/': DependencyRoll('src/', 'https://repo', 395 regression_deps_rolls = {'src/': DependencyRoll('src/', 'https://repo',
391 '1', '2')} 396 '1', '2')}
392 397
393 self.assertEqual(findit_for_crash.FindItForCrash( 398 self.assertEqual(findit_for_crash.FindItForCrash(
394 Stacktrace(), regression_deps_rolls, {}), []) 399 Stacktrace(), regression_deps_rolls, {}), [])
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698