| 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 Result, MatchResult |
| 10 from crash.scorers.min_distance import MinDistance |
| 11 |
| 12 DUMMY_CHANGELOG = ChangeLog.FromDict({ |
| 13 'author_name': 'r@chromium.org', |
| 14 'message': 'dummy', |
| 15 'committer_email': 'r@chromium.org', |
| 16 'commit_position': 175900, |
| 17 'author_email': 'r@chromium.org', |
| 18 'touched_files': [ |
| 19 { |
| 20 'change_type': 'add', |
| 21 'new_path': 'a.cc', |
| 22 'old_path': None, |
| 23 }, |
| 24 ], |
| 25 'author_time': 'Thu Mar 31 21:24:43 2016', |
| 26 'committer_time': 'Thu Mar 31 21:28:39 2016', |
| 27 'commit_url': |
| 28 'https://repo.test/+/1', |
| 29 'code_review_url': 'https://codereview.chromium.org/3281', |
| 30 'committer_name': 'example@chromium.org', |
| 31 'revision': '1', |
| 32 'reverted_revision': None |
| 33 }) |
| 34 |
| 35 |
| 36 class MinDistanceTest(testing.AppengineTestCase): |
| 37 |
| 38 def testGetMetric(self): |
| 39 match_result = MatchResult(DUMMY_CHANGELOG, 'src/', '') |
| 40 match_result.min_distance = 0 |
| 41 |
| 42 self.assertEqual(MinDistance().GetMetric(match_result), 0) |
| 43 |
| 44 result = Result(DUMMY_CHANGELOG, 'src/', '') |
| 45 self.assertEqual(MinDistance().GetMetric(result), None) |
| 46 |
| 47 def testScore(self): |
| 48 self.assertEqual(MinDistance().Score(0), 1) |
| 49 self.assertEqual(MinDistance().Score(30), 0.8) |
| 50 self.assertEqual(MinDistance().Score(60), 0) |
| 51 |
| 52 def testReason(self): |
| 53 self.assertEqual(MinDistance().Reason(0, 1), |
| 54 'Minimum distance to crashed line is 0') |
| 55 self.assertEqual(MinDistance().Reason(60, 0), |
| 56 '') |
| OLD | NEW |