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

Side by Side Diff: appengine/findit/crash/scorers/test/min_distance_test.py

Issue 2157433002: [Findit] Pass changed files info to Fracas, 2 face design. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Fix nits. Created 4 years, 5 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 from crash.callstack import StackFrame
5 from crash.results import Result, MatchResult 5 from crash.results import Result, MatchResult
6 from crash.scorers.min_distance import MinDistance 6 from crash.scorers.min_distance import MinDistance
7 from crash.scorers.test.scorer_test_suite import ScorerTestSuite 7 from crash.scorers.test.scorer_test_suite import ScorerTestSuite
8 8
9 9
10 class MinDistanceTest(ScorerTestSuite): 10 class MinDistanceTest(ScorerTestSuite):
11 11
12 def testGetMetric(self): 12 def testGetMetric(self):
13 dummy_changelog = self._GetDummyChangeLog() 13 dummy_changelog = self._GetDummyChangeLog()
14 match_result = MatchResult(dummy_changelog, 'src/', '') 14 match_result = MatchResult(dummy_changelog, 'src/', '')
15 match_result.min_distance = 0 15 match_result.file_to_analysis_info = {
16 'file': {'min_distance': 0, 'min_distance_frame': None}
17 }
16 18
17 self.assertEqual(MinDistance().GetMetric(match_result), 0) 19 self.assertEqual(MinDistance().GetMetric(match_result), 0)
18 20
19 result = Result(dummy_changelog, 'src/', '') 21 result = Result(dummy_changelog, 'src/', '')
20 self.assertEqual(MinDistance().GetMetric(result), None) 22 self.assertEqual(MinDistance().GetMetric(result), float('inf'))
21 23
22 def testScore(self): 24 def testScore(self):
23 self.assertEqual(MinDistance().Score(0), 1) 25 self.assertEqual(MinDistance().Score(0), 1)
24 self.assertEqual(MinDistance().Score(30), 0.8) 26 self.assertEqual(MinDistance().Score(30), 0.8)
25 self.assertEqual(MinDistance().Score(60), 0) 27 self.assertEqual(MinDistance().Score(60), 0)
26 28
27 def testReason(self): 29 def testReason(self):
28 self.assertEqual(MinDistance().Reason(0, 1), 30 self.assertEqual(MinDistance().Reason(0, 1),
29 'Modification distance (LOC) is 0') 31 ('MinDistance', 1, 'Minimum distance is 0'))
30 self.assertEqual(MinDistance().Reason(60, 0), 32 self.assertEqual(MinDistance().Reason(60, 0),
31 '') 33 None)
34
35 def testChangedFiles(self):
36 dummy_changelog = self._GetDummyChangeLog()
37 result = MatchResult(dummy_changelog, 'src/', '')
38 frame = StackFrame(0, 'src/', 'func', 'f.cc', 'a/b/src/f.cc', [2],
39 repo_url='https://repo_url')
40 result.file_to_stack_infos = {
41 'src/f.cc': [(frame, 0)]
42 }
43 result.file_to_analysis_info = {
44 'src/f.cc': {'min_distance': 0, 'min_distance_frame': frame}
45 }
46
47 self.assertEqual(MinDistance().ChangedFiles(result),
48 [{'file': 'f.cc',
49 'blame_url': ('https://repo_url/+blame/%s/f.cc#2' %
50 dummy_changelog.revision),
51 'info': 'Minimum distance (LOC) 0, frame #0'}])
52
OLDNEW
« no previous file with comments | « appengine/findit/crash/scorers/test/aggregators_test.py ('k') | appengine/findit/crash/scorers/test/top_frame_index_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698