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

Unified Diff: appengine/findit/crash/test/results_test.py

Issue 2588513002: [Predator] renamed "Result" to "Suspect" (Closed)
Patch Set: Removing redundant import Created 4 years 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/test/project_classifier_test.py ('k') | appengine/findit/crash/test/suspect_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: appengine/findit/crash/test/results_test.py
diff --git a/appengine/findit/crash/test/results_test.py b/appengine/findit/crash/test/results_test.py
deleted file mode 100644
index 51277ac385fb279697794659637a6e1f39109ffc..0000000000000000000000000000000000000000
--- a/appengine/findit/crash/test/results_test.py
+++ /dev/null
@@ -1,200 +0,0 @@
-# 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.results import AnalysisInfo
-from crash.results import MatchResult
-from crash.results import MatchResults
-from crash.results import Result
-from crash.results import StackInfo
-from crash.stacktrace import StackFrame
-from crash.test.crash_test_suite import CrashTestSuite
-from libs.gitiles.blame import Blame
-from libs.gitiles.blame import Region
-from libs.gitiles.change_log import ChangeLog
-
-DUMMY_CHANGELOG1 = ChangeLog.FromDict({
- 'author_name': 'r@chromium.org',
- 'message': 'dummy',
- 'committer_email': 'r@chromium.org',
- 'commit_position': 175900,
- 'author_email': 'r@chromium.org',
- 'touched_files': [
- {
- 'change_type': 'modify',
- 'new_path': 'a.cc',
- 'old_path': 'a.cc',
- },
- {
- 'change_type': 'modify',
- 'new_path': 'b.cc',
- 'old_path': 'b.cc',
- },
- ],
- 'author_time': 'Thu Mar 31 21:24:43 2016',
- 'committer_time': 'Thu Mar 31 21:28:39 2016',
- 'commit_url':
- 'https://repo.test/+/1',
- 'code_review_url': 'https://codereview.chromium.org/3281',
- 'committer_name': 'r',
- 'revision': '1',
- 'reverted_revision': None
-})
-
-DUMMY_CHANGELOG2 = ChangeLog.FromDict({
- 'author_name': 'e@chromium.org',
- 'message': 'dummy',
- 'committer_email': 'e@chromium.org',
- 'commit_position': 175911,
- 'author_email': 'e@chromium.org',
- 'touched_files': [
- {
- 'change_type': 'modify',
- 'new_path': 'a.cc',
- 'old_path': 'a.cc',
- },
- ],
- 'author_time': 'Thu Mar 31 21:24:43 2016',
- 'committer_time': 'Thu Mar 31 21:28:39 2016',
- 'commit_url':
- 'https://repo.test/+/2',
- 'code_review_url': 'https://codereview.chromium.org/3290',
- 'committer_name': 'e',
- 'revision': '2',
- 'reverted_revision': None
-})
-
-DUMMY_BLAME = Blame('4', 'a.cc')
-DUMMY_BLAME.AddRegion(
- Region(1, 5, '2', 'r', 'r@chromium.org', 'Thu Mar 25 21:24:43 2016'))
-DUMMY_BLAME.AddRegion(
- Region(6, 3, '1', 'e', 'e@chromium.org', 'Thu Mar 31 21:24:43 2016'))
-DUMMY_BLAME.AddRegion(
- Region(9, 2, '3', 'k', 'k@chromium.org', 'Thu Apr 1 21:24:43 2016'))
-
-DUMMY_BLAME2 = Blame('4', 'b.cc')
-DUMMY_BLAME2.AddRegion(
- Region(1, 5, '2', 'r', 'r@chromium.org', 'Thu Mar 25 21:24:43 2016'))
-DUMMY_BLAME2.AddRegion(
- Region(6, 3, '1', 'e', 'e@chromium.org', 'Thu Mar 31 21:24:43 2016'))
-
-
-class ResultsTest(CrashTestSuite):
-
- def testResultToDict(self):
-
- result = Result(DUMMY_CHANGELOG1, 'src/',
- confidence=1, reasons=['MinDistance', 0.5, 'some reason'],
- changed_files={'file': 'f', 'blame_url': 'http://b',
- 'info': 'min distance (LOC) 5'})
-
- expected_result_json = {
- 'url': DUMMY_CHANGELOG1.commit_url,
- 'review_url': DUMMY_CHANGELOG1.code_review_url,
- 'revision': DUMMY_CHANGELOG1.revision,
- 'project_path': 'src/',
- 'author': DUMMY_CHANGELOG1.author_email,
- 'time': str(DUMMY_CHANGELOG1.author_time),
- 'reasons': ['MinDistance', 0.5, 'some reason'],
- 'changed_files': {'file': 'f', 'blame_url': 'http://b',
- 'info': 'min distance (LOC) 5'},
- 'confidence': 1,
- }
-
- self.assertEqual(result.ToDict(), expected_result_json)
-
- def testResultToString(self):
-
- result = Result(DUMMY_CHANGELOG1, 'src/', confidence=1)
-
- expected_result_str = ''
- self.assertEqual(result.ToString(), expected_result_str)
-
- result.file_to_stack_infos = {
- 'a.cc': [StackInfo(
- frame = StackFrame(0, 'src/', 'func', 'a.cc', 'src/a.cc', []),
- priority = 0)]
- }
- expected_result_str = 'Changed file a.cc crashed in frame #0'
-
- self.assertEqual(str(result), expected_result_str)
-
- def testMatchResultUpdate(self):
- # Touched lines have intersection with crashed lines.
- result = MatchResult(DUMMY_CHANGELOG1, 'src/', confidence=1)
- stack_infos = [StackInfo(
- frame = StackFrame(0, 'src/', 'func', 'a.cc', 'src/a.cc', [7]),
- priority = 0)]
-
- result.Update('a.cc', stack_infos, DUMMY_BLAME)
- self.assertEqual(result.file_to_analysis_info['a.cc'].min_distance, 0)
-
- # Touched lines are before crashed lines.
- result = MatchResult(DUMMY_CHANGELOG1, 'src/', confidence=1)
-
- stack_infos = [StackInfo(
- frame = StackFrame(0, 'src/', 'func', 'a.cc', 'src/a.cc', [3]),
- priority = 0)]
-
- result.Update('a.cc', stack_infos, DUMMY_BLAME)
- self.assertEqual(result.file_to_analysis_info['a.cc'].min_distance, 3)
-
- # Touched lines are after crashed lines.
- result = MatchResult(DUMMY_CHANGELOG1, 'src/', confidence=1)
-
- stack_infos = [StackInfo(
- frame = StackFrame(0, 'src/', 'func', 'a.cc', 'src/a.cc', [10]),
- priority = 0)]
-
- result.Update('a.cc', stack_infos, DUMMY_BLAME)
- self.assertEqual(result.file_to_analysis_info['a.cc'].min_distance, 2)
-
- def testMatchResultUpdateWithEmptyBlame(self):
- result = MatchResult(DUMMY_CHANGELOG1, 'src/', confidence=1)
- stack_infos = [StackInfo(
- frame = StackFrame(0, 'src/', 'func', 'a.cc', 'src/a.cc', [7]),
- priority = 0)]
-
- result.Update('a.cc', stack_infos, None)
- self.assertEqual(result.file_to_stack_infos['a.cc'], stack_infos)
- self.assertEqual(result.file_to_analysis_info, {})
-
- def testMatchResultUpdateMinimumDistance(self):
- result = MatchResult(DUMMY_CHANGELOG1, 'src/', confidence=1)
- frame1 = StackFrame(0, 'src/', 'func', 'a.cc', 'src/a.cc', [7])
- frame2 = StackFrame(2, 'src/', 'func', 'a.cc', 'src/a.cc', [20])
- stack_infos = [StackInfo(frame1, 0), StackInfo(frame2, 0)]
-
- result.Update('a.cc', stack_infos, DUMMY_BLAME)
- self.assertEqual(result.file_to_stack_infos['a.cc'], stack_infos)
- self.assertEqual(result.file_to_analysis_info,
- {'a.cc': AnalysisInfo(min_distance = 0, min_distance_frame = frame1)})
-
- def testMatchResultsGenerateMatchResults(self):
- match_results = MatchResults(ignore_cls=set(['2']))
- frame1 = StackFrame(0, 'src/', 'func', 'a.cc', 'src/a.cc', [7])
- frame2 = StackFrame(1, 'src/', 'func', 'b.cc', 'src/b.cc', [11])
- stack_infos1 = [StackInfo(frame1, 0)]
- stack_infos2 = [StackInfo(frame2, 0)]
- match_results.GenerateMatchResults('a.cc', 'src/', stack_infos1,
- [DUMMY_CHANGELOG1, DUMMY_CHANGELOG2],
- DUMMY_BLAME)
-
- match_results.GenerateMatchResults('b.cc', 'src/', stack_infos2,
- [DUMMY_CHANGELOG1, DUMMY_CHANGELOG2],
- DUMMY_BLAME2)
-
- expected_match_result = MatchResult(DUMMY_CHANGELOG1, 'src/')
- expected_match_result.file_to_stack_infos = {
- 'a.cc': stack_infos1,
- 'b.cc': stack_infos2,
- }
- expected_match_result.file_to_analysis_info = {
- 'a.cc': AnalysisInfo(min_distance = 0, min_distance_frame = frame1),
- 'b.cc': AnalysisInfo(min_distance = 3, min_distance_frame = frame2),
- }
-
- expected_match_results = MatchResults(ignore_cls=set(['2']))
- expected_match_results['1'] = expected_match_result
-
- self._VerifyTwoMatchResultsEqual(match_results, expected_match_results)
« no previous file with comments | « appengine/findit/crash/test/project_classifier_test.py ('k') | appengine/findit/crash/test/suspect_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698