| Index: appengine/findit/crash/test/findit_for_chromecrash_test.py
|
| diff --git a/appengine/findit/crash/test/findit_for_chromecrash_test.py b/appengine/findit/crash/test/findit_for_chromecrash_test.py
|
| index 230d0711a311de8ac19c99ed4363d8ab5f9d536a..b0812da40c4109844a48c630799230f5cb47f523 100644
|
| --- a/appengine/findit/crash/test/findit_for_chromecrash_test.py
|
| +++ b/appengine/findit/crash/test/findit_for_chromecrash_test.py
|
| @@ -4,94 +4,85 @@
|
|
|
| from common import chromium_deps
|
| from common.dependency import DependencyRoll
|
| -from crash import detect_regression_range
|
| -from crash import findit_for_chromecrash
|
| +from crash import changelist_classifier
|
| +from crash import findit
|
| +from crash.findit_for_chromecrash import FinditForChromeCrash
|
| from crash import chromecrash_parser
|
| -from crash import findit_for_crash
|
| from crash.component_classifier import ComponentClassifier
|
| from crash.project_classifier import ProjectClassifier
|
| +from crash.changelist_classifier import ChangelistClassifier
|
| from crash.results import MatchResult
|
| from crash.stacktrace import CallStack
|
| from crash.stacktrace import Stacktrace
|
| +from crash.culprit import NullCulprit
|
| from crash.test.crash_testcase import CrashTestCase
|
| +from model.crash.crash_analysis import CrashAnalysis
|
|
|
|
|
| class FinditForChromeCrashTest(CrashTestCase):
|
|
|
| def testFindCulpritForChromeCrashEmptyStacktrace(self):
|
| - def _MockGetChromeDependency(*_):
|
| - return {}
|
| -
|
| - def _MockParse(*_):
|
| - return Stacktrace()
|
| -
|
| - self.mock(chromium_deps, 'GetChromeDependency', _MockGetChromeDependency)
|
| - self.mock(chromecrash_parser.ChromeCrashParser, 'Parse', _MockParse)
|
| + self.mock(chromium_deps, 'GetChromeDependency', lambda *_: {})
|
| + self.mock(chromecrash_parser.ChromeCrashParser, 'Parse',
|
| + lambda *_: Stacktrace())
|
|
|
| expected_results = {'found': False}
|
| expected_tag = {'found_suspects': False,
|
| 'has_regression_range': False}
|
|
|
| - results, tag = findit_for_chromecrash.FinditForChromeCrash().FindCulprit(
|
| - 'signature', 'win', 'frame1\nframe2', '50.0.1234.0',
|
| - [{'chrome_version': '50.0.1234.0', 'cpm': 0.6}]).ToDicts()
|
| + analysis = CrashAnalysis()
|
| + analysis.signature = 'signature'
|
| + analysis.platform = 'win'
|
| + analysis.stack_trace = 'frame1\nframe2'
|
| + analysis.crashed_version = '50.0.1234.0'
|
| + analysis.historical_metadata = [{'chrome_version': '51.0.1234.0', 'cpm': 0.6}]
|
| + results, tag = FinditForChromeCrash().FindCulprit(analysis).ToDicts()
|
|
|
| - self.assertEqual(expected_results, results)
|
| - self.assertEqual(expected_tag, tag)
|
| + self.assertDictEqual(expected_results, results)
|
| + self.assertDictEqual(expected_tag, tag)
|
|
|
| def testFindCulpritForChromeCrash(self):
|
| - def _MockGetChromeDependency(*_):
|
| - return {}
|
| + self.mock(chromium_deps, 'GetChromeDependency', lambda *_: {})
|
|
|
| - def _MockParse(*_):
|
| - stack = Stacktrace()
|
| - stack.append(CallStack(0))
|
| - return stack
|
| + self.mock(chromecrash_parser.ChromeCrashParser, 'Parse',
|
| + lambda *_: Stacktrace([CallStack(0)]))
|
|
|
| - def _MockGetDEPSRollsDict(*_):
|
| - return {'src/': DependencyRoll('src/', 'https://repo', '1', '2'),
|
| - 'src/add': DependencyRoll('src/add', 'https://repo1', None, '2'),
|
| - 'src/delete': DependencyRoll('src/delete', 'https://repo2',
|
| - '2', None)}
|
| + self.mock(chromium_deps, 'GetDEPSRollsDict', lambda *_: {
|
| + 'src/': DependencyRoll('src/', 'https://repo', '1', '2'),
|
| + 'src/add': DependencyRoll('src/add', 'https://repo1', None, '2'),
|
| + 'src/delete': DependencyRoll('src/delete', 'https://repo2', '2', None)
|
| + })
|
|
|
| dummy_match_result = MatchResult(self.GetDummyChangeLog(), 'src/')
|
| - def _MockFindItForCrash(*args):
|
| - regression_deps_rolls = args[1]
|
| - if regression_deps_rolls:
|
| - return [dummy_match_result]
|
| -
|
| - return []
|
| -
|
| - def _MockComponentClassify(*_):
|
| - return []
|
| -
|
| - def _MockProjectClassify(*_):
|
| - return ''
|
| -
|
| - self.mock(chromium_deps, 'GetChromeDependency', _MockGetChromeDependency)
|
| - self.mock(chromecrash_parser.ChromeCrashParser, 'Parse', _MockParse)
|
| - self.mock(chromium_deps, 'GetDEPSRollsDict', _MockGetDEPSRollsDict)
|
| - self.mock(findit_for_crash, 'FindItForCrash', _MockFindItForCrash)
|
| -
|
| - self.mock(ComponentClassifier, 'Classify', _MockComponentClassify)
|
| - self.mock(ProjectClassifier, 'Classify', _MockProjectClassify)
|
| -
|
| - expected_results = {'found': False}
|
| - expected_tag = {'found_suspects': False}
|
| -
|
| - results, tag = findit_for_chromecrash.FinditForChromeCrash().FindCulprit(
|
| - 'signature', 'win', 'frame1\nframe2', '50.0.1234.0',
|
| - ['50.0.1233.0', '50.0.1234.0']).ToDicts()
|
| + self.mock(changelist_classifier.ChangelistClassifier, '__call__',
|
| + lambda _self, regression_deps_rolls, *args:
|
| + [dummy_match_result] if regression_deps_rolls else [])
|
| +
|
| + self.mock(ComponentClassifier, 'Classify', lambda *_: [])
|
| + self.mock(ProjectClassifier, 'Classify', lambda *_: '')
|
| +
|
| + # TODO(wrengr): for both these tests, we should compare Culprit
|
| + # objects directly rather than calling ToDicts and comparing the
|
| + # dictionaries.
|
| + self._testFindCulpritForChromeCrashSucceeds(dummy_match_result)
|
| + self._testFindCulpritForChromeCrashFails()
|
| +
|
| + def _testFindCulpritForChromeCrashSucceeds(self, dummy_match_result):
|
| + analysis = CrashAnalysis()
|
| + analysis.signature = 'signature'
|
| + analysis.platform = 'win'
|
| + analysis.stack_trace = 'frame1\nframe2'
|
| + analysis.crashed_version = '50.0.1234.0'
|
| + dummy_regression_range = ['50.0.1233.0', '50.0.1234.0']
|
| + analysis.regression_range = dummy_regression_range
|
| + results, tag = FinditForChromeCrash().FindCulprit(analysis).ToDicts()
|
|
|
| - # TODO(wrengr): compare the Culprit object directly to these values,
|
| - # rather than converting to dicts first. We can make a different
|
| - # unit test for comparing the dicts, if we actually need/want to.
|
| expected_results = {
|
| 'found': True,
|
| 'suspected_project': '',
|
| 'suspected_components': [],
|
| 'suspected_cls': [dummy_match_result.ToDict()],
|
| - 'regression_range': ['50.0.1233.0', '50.0.1234.0']
|
| + 'regression_range': dummy_regression_range
|
| }
|
| expected_tag = {
|
| 'found_suspects': True,
|
| @@ -101,26 +92,19 @@ class FinditForChromeCrashTest(CrashTestCase):
|
| 'solution': 'core_algorithm',
|
| }
|
|
|
| - self.assertEqual(expected_results, results)
|
| - self.assertEqual(expected_tag, tag)
|
| + self.assertDictEqual(expected_results, results)
|
| + self.assertDictEqual(expected_tag, tag)
|
|
|
| - results, tag = findit_for_chromecrash.FinditForChromeCrash().FindCulprit(
|
| - 'signature', 'win', 'frame1\nframe2', '50.0.1234.0', None).ToDicts()
|
| + def _testFindCulpritForChromeCrashFails(self):
|
| + analysis = CrashAnalysis()
|
| + analysis.signature = 'signature'
|
| + analysis.platform = 'win'
|
| + analysis.stack_trace = 'frame1\nframe2'
|
| + analysis.crashed_version = '50.0.1234.0'
|
| + analysis.historical_metadata = []
|
| + results, tag = FinditForChromeCrash().FindCulprit(analysis).ToDicts()
|
|
|
| - expected_results = {
|
| - 'found': False,
|
| - 'suspected_project': '',
|
| - 'suspected_components': [],
|
| - 'suspected_cls': [],
|
| - 'regression_range': None
|
| - }
|
| - expected_tag = {
|
| - 'found_suspects': False,
|
| - 'found_project': False,
|
| - 'found_components': False,
|
| - 'has_regression_range': False,
|
| - 'solution': 'core_algorithm',
|
| - }
|
| + expected_results, expected_tag = NullCulprit().ToDicts()
|
|
|
| - self.assertEqual(expected_results, results)
|
| - self.assertEqual(expected_tag, tag)
|
| + self.assertDictEqual(expected_results, results)
|
| + self.assertDictEqual(expected_tag, tag)
|
|
|