| OLD | NEW |
| (Empty) | |
| 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 |
| 3 # found in the LICENSE file. |
| 4 |
| 5 from testing_utils import testing |
| 6 |
| 7 from common.change_log import ChangeLog |
| 8 from crash.callstack import StackFrame |
| 9 from crash.results import MatchResult |
| 10 from crash.scorers.aggregator import Aggregator |
| 11 from crash.scorers.min_distance import MinDistance |
| 12 from crash.scorers.top_frame_index import TopFrameIndex |
| 13 |
| 14 DUMMY_CHANGELOG = ChangeLog.FromDict({ |
| 15 'author_name': 'r@chromium.org', |
| 16 'message': 'dummy', |
| 17 'committer_email': 'r@chromium.org', |
| 18 'commit_position': 175900, |
| 19 'author_email': 'r@chromium.org', |
| 20 'touched_files': [ |
| 21 { |
| 22 'change_type': 'add', |
| 23 'new_path': 'a.cc', |
| 24 'old_path': None, |
| 25 }, |
| 26 ], |
| 27 'author_time': 'Thu Mar 31 21:24:43 2016', |
| 28 'committer_time': 'Thu Mar 31 21:28:39 2016', |
| 29 'commit_url': |
| 30 'https://repo.test/+/1', |
| 31 'code_review_url': 'https://codereview.chromium.org/3281', |
| 32 'committer_name': 'example@chromium.org', |
| 33 'revision': '1', |
| 34 'reverted_revision': None |
| 35 }) |
| 36 |
| 37 |
| 38 class AggregatorTest(testing.AppengineTestCase): |
| 39 |
| 40 def testScoreAndReason(self): |
| 41 result = MatchResult(DUMMY_CHANGELOG, 'src/', '') |
| 42 result.file_to_stack_infos = { |
| 43 'a.cc': [(StackFrame(0, 'src/', '', 'func', 'a.cc', [7]), 0)] |
| 44 } |
| 45 result.min_distance = 0 |
| 46 |
| 47 aggregator = Aggregator([TopFrameIndex(), MinDistance()]) |
| 48 aggregator.ScoreAndReason(result) |
| 49 |
| 50 self.assertEqual(result.confidence, 1) |
| 51 self.assertEqual(result.reason, |
| 52 ('1. Top frame changed is frame #0 (score: 1)\n' |
| 53 '2. Minimum distance to crashed line is 0 (score: 1)\n' |
| 54 '\nChanged file a.cc which crashed in func (#0)')) |
| OLD | NEW |