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

Unified Diff: appengine/findit/crash/loglinear/changelist_features/test/top_frame_index_test.py

Issue 2613153006: [Predator] Add TouchCrashedFileMetaFeature. (Closed)
Patch Set: Add comments. Created 3 years, 11 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
Index: appengine/findit/crash/loglinear/changelist_features/test/top_frame_index_test.py
diff --git a/appengine/findit/crash/loglinear/changelist_features/test/top_frame_index_test.py b/appengine/findit/crash/loglinear/changelist_features/test/top_frame_index_test.py
index f7ae09f11e341a83672ced987d01f3483b15285e..23f55037a2aea446eee1b332691ed9adddfbab70 100644
--- a/appengine/findit/crash/loglinear/changelist_features/test/top_frame_index_test.py
+++ b/appengine/findit/crash/loglinear/changelist_features/test/top_frame_index_test.py
@@ -9,10 +9,12 @@ from crash.suspect import Suspect
from crash.suspect import StackInfo
from crash.stacktrace import StackFrame
from libs.gitiles.change_log import ChangeLog
+from libs.gitiles.change_log import FileChangeInfo
+from libs.gitiles.diff import ChangeType
import libs.math.logarithms as lmath
-_MAXIMUM = float(top_frame_index._MAX_FRAME_INDEX)
+_MAXIMUM = 7
_DUMMY_CHANGELOG = ChangeLog.FromDict({
'author': {
@@ -42,7 +44,8 @@ _DUMMY_CHANGELOG = ChangeLog.FromDict({
})
-class TopFrameIndexTest(unittest.TestCase):
+class TopFrameIndexFeatureTest(unittest.TestCase):
+ """Tests ``TopFrameIndexFeature``."""
def _GetDummyChangeLog(self):
return _DUMMY_CHANGELOG
@@ -50,52 +53,34 @@ class TopFrameIndexTest(unittest.TestCase):
def _GetDummyReport(self):
return None
- def _GetMockSuspect(self, mock_top_frame_index):
+ def _GetMockSuspect(self):
"""Returns a ``Suspect`` with the desired top frame index."""
dep_path = 'src/'
- suspect = Suspect(self._GetDummyChangeLog(), dep_path)
- suspect.file_to_stack_infos = {
- 'a.cc': [StackInfo(
- frame = StackFrame(
- index = mock_top_frame_index,
- dep_path = dep_path,
- function = 'func',
- file_path = 'a.cc',
- raw_file_path = 'a.cc',
- crashed_line_numbers = [7]),
- priority = 0)]
- }
- return suspect
+ return Suspect(self._GetDummyChangeLog(), dep_path)
def testTopFrameIndexNone(self):
- """Test that the feature returns log(0) when there are no frames."""
+ """Test that the feature returns log(0) when there are no matched files."""
report = self._GetDummyReport()
suspect = Suspect(self._GetDummyChangeLog(), 'src/')
- self.assertEqual(lmath.LOG_ZERO,
- top_frame_index.TopFrameIndexFeature()(report)(suspect).value)
+ self.assertEqual(
+ lmath.LOG_ZERO,
+ top_frame_index.TopFrameIndexFeature(3)(report)(
+ suspect, {}).value)
def testTopFrameIndexIsZero(self):
"""Test that the feature returns log(1) when the top frame index is 0."""
report = self._GetDummyReport()
- suspect = self._GetMockSuspect(0)
+ suspect = self._GetMockSuspect()
+ touched_file_to_stack_infos = {
+ FileChangeInfo(ChangeType.MODIFY, 'a.cc', 'a.cc'):
+ [StackInfo(frame=StackFrame(index=0,
+ dep_path=suspect.dep_path,
+ function='func',
+ file_path='a.cc',
+ raw_file_path='a.cc',
+ crashed_line_numbers=[7]),
+ priority = 0)]
+ }
self.assertEqual(lmath.LOG_ONE,
- top_frame_index.TopFrameIndexFeature()(report)(suspect).value)
-
- def testTopFrameIndexMiddling(self):
- """Test that the feature returns middling scores for middling indices."""
- report = self._GetDummyReport()
- suspect = self._GetMockSuspect(3)
- self.assertEqual(
- lmath.log((_MAXIMUM - 3.) / _MAXIMUM),
- top_frame_index.TopFrameIndexFeature()(report)(suspect).value)
-
- def testTopFrameIndexIsOverMax(self):
- """Test that we return log(0) when the top frame index is too large."""
- report = self._GetDummyReport()
- suspect = self._GetMockSuspect(_MAXIMUM + 1)
- self.assertEqual(lmath.LOG_ZERO,
- top_frame_index.TopFrameIndexFeature()(report)(suspect).value)
-
- suspect = self._GetMockSuspect(5)
- self.assertEqual(lmath.LOG_ZERO,
- top_frame_index.TopFrameIndexFeature(2)(report)(suspect).value)
+ top_frame_index.TopFrameIndexFeature(_MAXIMUM)(report)(
+ suspect, touched_file_to_stack_infos).value)

Powered by Google App Engine
This is Rietveld 408576698