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

Unified Diff: appengine/findit/crash/scorers/test/aggregated_scorer_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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « appengine/findit/crash/scorers/scorer.py ('k') | appengine/findit/crash/scorers/test/aggregator_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: appengine/findit/crash/scorers/test/aggregated_scorer_test.py
diff --git a/appengine/findit/crash/scorers/test/aggregated_scorer_test.py b/appengine/findit/crash/scorers/test/aggregated_scorer_test.py
new file mode 100644
index 0000000000000000000000000000000000000000..e9ea5405e9e62662e39b6eb208e0666f7c812b28
--- /dev/null
+++ b/appengine/findit/crash/scorers/test/aggregated_scorer_test.py
@@ -0,0 +1,62 @@
+# Copyright 2016 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+from crash.callstack import StackFrame
+from crash.results import MatchResult
+from crash.scorers import aggregators
+from crash.scorers.aggregated_scorer import AggregatedScorer
+from crash.scorers.min_distance import MinDistance
+from crash.scorers.test.scorer_test_suite import ScorerTestSuite
+from crash.scorers.top_frame_index import TopFrameIndex
+
+
+class AggregatedScorerTest(ScorerTestSuite):
+
+ def testScore(self):
+ result = MatchResult(self._GetDummyChangeLog(), 'src/', '')
+ frame = StackFrame(0, 'src/', 'func', 'a.cc', 'src/a.cc', [7],
+ repo_url='https://repo_url')
+ result.file_to_stack_infos = {
+ 'a.cc': [(frame, 0)]
+ }
+ result.file_to_analysis_info = {
+ 'a.cc': {
+ 'min_distance': 0,
+ 'min_distance_frame': frame
+ }
+ }
+
+ aggregator = AggregatedScorer([TopFrameIndex(), MinDistance()])
+ aggregator.Score(result)
+
+ self.assertEqual(result.confidence, 1)
+ self.assertEqual(result.reasons,
+ [('TopFrameIndex', 1.0, 'Top frame is #0'),
+ ('MinDistance', 1, 'Minimum distance is 0')])
+ self.assertEqual(result.changed_files,
+ [{'info': 'Minimum distance (LOC) 0, frame #0',
+ 'blame_url': 'https://repo_url/+blame/1/a.cc#7',
+ 'file': 'a.cc'}])
+
+ def testScoreWithCustomizedAggregators(self):
+ result = MatchResult(self._GetDummyChangeLog(), 'src/', '')
+ frame = StackFrame(0, 'src/', 'func', 'a.cc', 'src/a.cc', [7],
+ repo_url='https://repo_url')
+ result.file_to_stack_infos = {
+ 'a.cc': [(frame, 0)]
+ }
+ result.file_to_analysis_info = {
+ 'a.cc': {
+ 'min_distance': 0,
+ 'min_distance_frame': frame
+ }
+ }
+
+ aggregator = AggregatedScorer([TopFrameIndex(), MinDistance()])
+ aggregator.Score(
+ result, score_aggregator=aggregators.IdentityAggregator(),
+ reasons_aggregator=aggregators.IdentityAggregator(),
+ changed_files_aggregator=aggregators.ChangedFilesAggregator())
+
+ self.assertEqual(result.confidence, [1, 1])
« no previous file with comments | « appengine/findit/crash/scorers/scorer.py ('k') | appengine/findit/crash/scorers/test/aggregator_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698