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

Side by Side Diff: appengine/findit/crash/test/results_test.py

Issue 1914113002: [Findit] Enable project classifier and component classifier (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Rebase Created 4 years, 7 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
5 from common.blame import Region, Blame 5 from common.blame import Region, Blame
6 from common.change_log import ChangeLog 6 from common.change_log import ChangeLog
7 from crash.callstack import StackFrame 7 from crash.callstack import StackFrame
8 from crash.results import Result, MatchResult, MatchResults 8 from crash.results import Result, MatchResult, MatchResults
9 from crash.test.crash_test_suite import CrashTestSuite 9 from crash.test.crash_test_suite import CrashTestSuite
10 10
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 DUMMY_BLAME.AddRegion( 71 DUMMY_BLAME.AddRegion(
72 Region(1, 5, '2', 'r', 'r@chromium.org', 'Thu Mar 25 21:24:43 2016')) 72 Region(1, 5, '2', 'r', 'r@chromium.org', 'Thu Mar 25 21:24:43 2016'))
73 DUMMY_BLAME.AddRegion( 73 DUMMY_BLAME.AddRegion(
74 Region(6, 3, '1', 'e', 'e@chromium.org', 'Thu Mar 31 21:24:43 2016')) 74 Region(6, 3, '1', 'e', 'e@chromium.org', 'Thu Mar 31 21:24:43 2016'))
75 75
76 76
77 class ResultsTest(CrashTestSuite): 77 class ResultsTest(CrashTestSuite):
78 78
79 def testResultToDict(self): 79 def testResultToDict(self):
80 80
81 result = Result(DUMMY_CHANGELOG1, 'src/', '', 81 result = Result(DUMMY_CHANGELOG1, 'src/',
82 confidence=1, reason='some reason') 82 confidence=1, reason='some reason')
83 83
84 expected_result_json = { 84 expected_result_json = {
85 'url': DUMMY_CHANGELOG1.commit_url, 85 'url': DUMMY_CHANGELOG1.commit_url,
86 'review_url': DUMMY_CHANGELOG1.code_review_url, 86 'review_url': DUMMY_CHANGELOG1.code_review_url,
87 'revision': DUMMY_CHANGELOG1.revision, 87 'revision': DUMMY_CHANGELOG1.revision,
88 'project_path': 'src/', 88 'project_path': 'src/',
89 'author': DUMMY_CHANGELOG1.author_email, 89 'author': DUMMY_CHANGELOG1.author_email,
90 'time': str(DUMMY_CHANGELOG1.author_time), 90 'time': str(DUMMY_CHANGELOG1.author_time),
91 'reason': 'some reason', 91 'reason': 'some reason',
92 'confidence': 1, 92 'confidence': 1,
93 } 93 }
94 94
95 self.assertEqual(result.ToDict(), expected_result_json) 95 self.assertEqual(result.ToDict(), expected_result_json)
96 96
97 def testResultToString(self): 97 def testResultToString(self):
98 98
99 result = Result(DUMMY_CHANGELOG1, 'src/', '', 99 result = Result(DUMMY_CHANGELOG1, 'src/',
100 confidence=1, reason='some reason') 100 confidence=1, reason='some reason')
101 101
102 expected_result_str = '' 102 expected_result_str = ''
103 self.assertEqual(result.ToString(), expected_result_str) 103 self.assertEqual(result.ToString(), expected_result_str)
104 104
105 result.file_to_stack_infos = { 105 result.file_to_stack_infos = {
106 'a.cc': [(StackFrame(0, 'src/', '', 'func', 'a.cc', []), 0)] 106 'a.cc': [(StackFrame(0, 'src/', 'func', 'a.cc', 'src/a.cc', []), 0)]
107 } 107 }
108 expected_result_str = 'Changed file a.cc crashed in func (#0)' 108 expected_result_str = 'Changed file a.cc crashed in func (#0)'
109 109
110 self.assertEqual(str(result), expected_result_str) 110 self.assertEqual(str(result), expected_result_str)
111 111
112 def testMatchResultUpdate(self): 112 def testMatchResultUpdate(self):
113 # Touched lines have intersection with crashed lines. 113 # Touched lines have intersection with crashed lines.
114 result = MatchResult(DUMMY_CHANGELOG1, 'src/', '', 114 result = MatchResult(DUMMY_CHANGELOG1, 'src/',
115 confidence=1, reason='some reason') 115 confidence=1, reason='some reason')
116 stack_infos = [(StackFrame(0, 'src/', '', 'func', 'a.cc', [7]), 0)] 116 stack_infos = [(StackFrame(0, 'src/', 'func', 'a.cc', 'src/a.cc', [7]), 0)]
117 117
118 result.Update('a.cc', stack_infos, DUMMY_BLAME) 118 result.Update('a.cc', stack_infos, DUMMY_BLAME)
119 self.assertEqual(result.min_distance, 0) 119 self.assertEqual(result.min_distance, 0)
120 120
121 # Touched lines are before crashed lines. 121 # Touched lines are before crashed lines.
122 result = MatchResult(DUMMY_CHANGELOG1, 'src/', '', 122 result = MatchResult(DUMMY_CHANGELOG1, 'src/',
123 confidence=1, reason='some reason') 123 confidence=1, reason='some reason')
124 124
125 stack_infos = [(StackFrame(0, 'src/', '', 'func', 'a.cc', [3]), 0)] 125 stack_infos = [(StackFrame(0, 'src/', 'func', 'a.cc', 'src/a.cc', [3]), 0)]
126 126
127 result.Update('a.cc', stack_infos, DUMMY_BLAME) 127 result.Update('a.cc', stack_infos, DUMMY_BLAME)
128 self.assertEqual(result.min_distance, 3) 128 self.assertEqual(result.min_distance, 3)
129 129
130 # Touched lines are after crashed lines. 130 # Touched lines are after crashed lines.
131 result = MatchResult(DUMMY_CHANGELOG1, 'src/', '', 131 result = MatchResult(DUMMY_CHANGELOG1, 'src/',
132 confidence=1, reason='some reason') 132 confidence=1, reason='some reason')
133 133
134 stack_infos = [(StackFrame(0, 'src/', '', 'func', 'a.cc', [10]), 0)] 134 stack_infos = [(StackFrame(0, 'src/', 'func', 'a.cc', 'src/a.cc', [10]), 0)]
135 135
136 result.Update('a.cc', stack_infos, DUMMY_BLAME) 136 result.Update('a.cc', stack_infos, DUMMY_BLAME)
137 self.assertEqual(result.min_distance, 2) 137 self.assertEqual(result.min_distance, 2)
138 138
139 def testMatchResultsGenerateMatchResults(self): 139 def testMatchResultsGenerateMatchResults(self):
140 match_results = MatchResults(ignore_cls=set(['2'])) 140 match_results = MatchResults(ignore_cls=set(['2']))
141 stack_infos1 = [(StackFrame(0, 'src/', '', 'func', 'a.cc', [7]), 0)] 141 stack_infos1 = [(StackFrame(
142 stack_infos2 = [(StackFrame(1, 'src/', '', 'func', 'b.cc', [11]), 0)] 142 0, 'src/', 'func', 'a.cc', 'src/a.cc', [7]), 0)]
143 stack_infos2 = [(StackFrame(
144 1, 'src/', 'func', 'b.cc', 'src/b.cc', [11]), 0)]
143 match_results.GenerateMatchResults('a.cc', 'src/', stack_infos1, 145 match_results.GenerateMatchResults('a.cc', 'src/', stack_infos1,
144 [DUMMY_CHANGELOG1, DUMMY_CHANGELOG2], 146 [DUMMY_CHANGELOG1, DUMMY_CHANGELOG2],
145 DUMMY_BLAME) 147 DUMMY_BLAME)
146 148
147 match_results.GenerateMatchResults('b.cc', 'src/', stack_infos2, 149 match_results.GenerateMatchResults('b.cc', 'src/', stack_infos2,
148 [DUMMY_CHANGELOG1, DUMMY_CHANGELOG2], 150 [DUMMY_CHANGELOG1, DUMMY_CHANGELOG2],
149 DUMMY_BLAME2) 151 DUMMY_BLAME2)
150 152
151 expected_match_result = MatchResult(DUMMY_CHANGELOG1, 'src/', '') 153 expected_match_result = MatchResult(DUMMY_CHANGELOG1, 'src/')
152 expected_match_result.file_to_stack_infos = { 154 expected_match_result.file_to_stack_infos = {
153 'a.cc': stack_infos1, 155 'a.cc': stack_infos1,
154 'b.cc': stack_infos2 156 'b.cc': stack_infos2
155 } 157 }
156 expected_match_result.min_distance = 0 158 expected_match_result.min_distance = 0
157 159
158 expected_match_results = MatchResults(ignore_cls=set(['2'])) 160 expected_match_results = MatchResults(ignore_cls=set(['2']))
159 expected_match_results['1'] = expected_match_result 161 expected_match_results['1'] = expected_match_result
160 162
161 self._VerifyTwoMatchResultsEqual(match_results, expected_match_results) 163 self._VerifyTwoMatchResultsEqual(match_results, expected_match_results)
OLDNEW
« no previous file with comments | « appengine/findit/crash/test/project_classifier_test.py ('k') | appengine/findit/crash/test/stacktrace_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698