| Index: appengine/findit/crash/test/changelist_classifier_test.py
|
| diff --git a/appengine/findit/crash/test/findit_for_crash_test.py b/appengine/findit/crash/test/changelist_classifier_test.py
|
| similarity index 85%
|
| rename from appengine/findit/crash/test/findit_for_crash_test.py
|
| rename to appengine/findit/crash/test/changelist_classifier_test.py
|
| index 64137f81fb9cd175832c97d482933e419c177b5f..0552f242be04bac5fd7dfc262b7956ed596e8fbb 100644
|
| --- a/appengine/findit/crash/test/findit_for_crash_test.py
|
| +++ b/appengine/findit/crash/test/changelist_classifier_test.py
|
| @@ -4,20 +4,21 @@
|
|
|
| from collections import defaultdict
|
|
|
| -from common.blame import Region
|
| +from common import chromium_deps
|
| from common.blame import Blame
|
| +from common.blame import Region
|
| from common.change_log import ChangeLog
|
| from common.dependency import Dependency
|
| from common.dependency import DependencyRoll
|
| from common.git_repository import GitRepository
|
| -from crash import findit_for_crash
|
| +from crash import changelist_classifier
|
| +from crash.crash_report import CrashReport
|
| +from crash.results import MatchResult
|
| from crash.stacktrace import StackFrame
|
| from crash.stacktrace import CallStack
|
| from crash.stacktrace import Stacktrace
|
| -from crash.results import MatchResult
|
| from crash.test.crash_test_suite import CrashTestSuite
|
|
|
| -
|
| DUMMY_CHANGELOG1 = ChangeLog.FromDict({
|
| 'author_name': 'r@chromium.org',
|
| 'message': 'dummy',
|
| @@ -93,7 +94,7 @@ DUMMY_CHANGELOG3 = ChangeLog.FromDict({
|
| })
|
|
|
|
|
| -class FinditForCrashTest(CrashTestSuite):
|
| +class ChangelistClassifierTest(CrashTestSuite):
|
|
|
| def testGetDepsInCrashStack(self):
|
| crash_stack = CallStack(0)
|
| @@ -108,7 +109,7 @@ class FinditForCrashTest(CrashTestSuite):
|
| expected_stack_deps = {'src/': crash_deps['src/']}
|
|
|
| self.assertEqual(
|
| - findit_for_crash.GetDepsInCrashStack(crash_stack, crash_deps),
|
| + changelist_classifier.GetDepsInCrashStack(crash_stack, crash_deps),
|
| expected_stack_deps)
|
|
|
| def testGetChangeLogsForFilesGroupedByDeps(self):
|
| @@ -130,7 +131,7 @@ class FinditForCrashTest(CrashTestSuite):
|
| self.mock(GitRepository, 'GetChangeLogs', _MockGetChangeLogs)
|
|
|
| dep_file_to_changelogs, ignore_cls = (
|
| - findit_for_crash.GetChangeLogsForFilesGroupedByDeps(
|
| + changelist_classifier.GetChangeLogsForFilesGroupedByDeps(
|
| regression_deps_rolls, stack_deps))
|
| dep_file_to_changelogs_json = defaultdict(lambda: defaultdict(list))
|
| for dep, file_to_changelogs in dep_file_to_changelogs.iteritems():
|
| @@ -149,7 +150,6 @@ class FinditForCrashTest(CrashTestSuite):
|
| self.assertEqual(ignore_cls, set(['1']))
|
|
|
| def testGetStackInfosForFilesGroupedByDeps(self):
|
| -
|
| main_stack = CallStack(0)
|
| main_stack.extend(
|
| [StackFrame(0, 'src/', 'c(p* &d)', 'a.cc', 'src/a.cc', [177]),
|
| @@ -181,7 +181,7 @@ class FinditForCrashTest(CrashTestSuite):
|
| }
|
|
|
| dep_file_to_stack_infos = (
|
| - findit_for_crash.GetStackInfosForFilesGroupedByDeps(
|
| + changelist_classifier.GetStackInfosForFilesGroupedByDeps(
|
| stacktrace, crashed_deps))
|
|
|
| self.assertEqual(len(dep_file_to_stack_infos),
|
| @@ -245,27 +245,28 @@ class FinditForCrashTest(CrashTestSuite):
|
| 'changed_files': None
|
| }]
|
|
|
| - match_results = findit_for_crash.FindMatchResults(
|
| + match_results = changelist_classifier.FindMatchResults(
|
| dep_file_to_changelogs, dep_file_to_stack_infos, stack_deps)
|
| self.assertEqual([result.ToDict() for result in match_results],
|
| expected_match_results)
|
|
|
| def testFindItForCrashNoRegressionRange(self):
|
| + self.mock(chromium_deps, 'GetDEPSRollsDict', lambda *_: {})
|
| + self.mock(chromium_deps, 'GetChromeDependency', lambda *_: {})
|
| + report = CrashReport(None, None, None, Stacktrace(), None)
|
| self.assertEqual(
|
| - findit_for_crash.FindItForCrash(Stacktrace(), {}, {}, 7),
|
| - [])
|
| + changelist_classifier.ChangelistClassifier(7)(report), [])
|
|
|
| def testFindItForCrashNoMatchFound(self):
|
| + regression_deps_rolls = {
|
| + 'src/': DependencyRoll('src/', 'https://repo', '1', '2')}
|
|
|
| - def _MockFindMatchResults(*_):
|
| - return []
|
| -
|
| - self.mock(findit_for_crash, 'FindMatchResults', _MockFindMatchResults)
|
| + self.mock(changelist_classifier, 'FindMatchResults', lambda *_: [])
|
| + self.mock(chromium_deps, 'GetDEPSRollsDict', lambda *_: regression_deps_rolls)
|
| + self.mock(chromium_deps, 'GetChromeDependency', lambda *_: {})
|
|
|
| - regression_deps_rolls = {'src/': DependencyRoll('src/', 'https://repo',
|
| - '1', '2')}
|
| - self.assertEqual(findit_for_crash.FindItForCrash(
|
| - Stacktrace(), regression_deps_rolls, {}, 7), [])
|
| + report = CrashReport(None, None, None, Stacktrace(), None)
|
| + self.assertEqual(changelist_classifier.ChangelistClassifier(7)(report), [])
|
|
|
| def testFindItForCrash(self):
|
|
|
| @@ -291,7 +292,7 @@ class FinditForCrashTest(CrashTestSuite):
|
|
|
| return [match_result1, match_result2]
|
|
|
| - self.mock(findit_for_crash, 'FindMatchResults', _MockFindMatchResults)
|
| + self.mock(changelist_classifier, 'FindMatchResults', _MockFindMatchResults)
|
|
|
| expected_match_results = [
|
| {
|
| @@ -311,8 +312,10 @@ class FinditForCrashTest(CrashTestSuite):
|
| regression_deps_rolls = {'src/': DependencyRoll('src/', 'https://repo',
|
| '1', '2')}
|
|
|
| - results = findit_for_crash.FindItForCrash(Stacktrace(),
|
| - regression_deps_rolls, {}, 7)
|
| + self.mock(chromium_deps, 'GetDEPSRollsDict', lambda *_: regression_deps_rolls)
|
| + self.mock(chromium_deps, 'GetChromeDependency', lambda *_: {})
|
| + report = CrashReport(None, None, None, Stacktrace(), None)
|
| + results = changelist_classifier.ChangelistClassifier(7)(report)
|
| self.assertEqual([result.ToDict() for result in results],
|
| expected_match_results)
|
|
|
| @@ -348,7 +351,7 @@ class FinditForCrashTest(CrashTestSuite):
|
|
|
| return [match_result1, match_result2, match_result3]
|
|
|
| - self.mock(findit_for_crash, 'FindMatchResults', _MockFindMatchResults)
|
| + self.mock(changelist_classifier, 'FindMatchResults', _MockFindMatchResults)
|
|
|
| expected_match_results = [
|
| {
|
| @@ -376,8 +379,10 @@ class FinditForCrashTest(CrashTestSuite):
|
| regression_deps_rolls = {'src/': DependencyRoll('src/', 'https://repo',
|
| '1', '2')}
|
|
|
| - results = findit_for_crash.FindItForCrash(Stacktrace(),
|
| - regression_deps_rolls, {}, 7)
|
| + self.mock(chromium_deps, 'GetDEPSRollsDict', lambda *_: regression_deps_rolls)
|
| + self.mock(chromium_deps, 'GetChromeDependency', lambda *_: {})
|
| + report = CrashReport(None, None, None, Stacktrace(), None)
|
| + results = changelist_classifier.ChangelistClassifier(7)(report)
|
|
|
| self.assertEqual([result.ToDict() for result in results],
|
| expected_match_results)
|
| @@ -406,10 +411,12 @@ class FinditForCrashTest(CrashTestSuite):
|
|
|
| return [match_result1, match_result2]
|
|
|
| - self.mock(findit_for_crash, 'FindMatchResults', _MockFindMatchResults)
|
| + self.mock(changelist_classifier, 'FindMatchResults', _MockFindMatchResults)
|
|
|
| regression_deps_rolls = {'src/': DependencyRoll('src/', 'https://repo',
|
| '1', '2')}
|
|
|
| - self.assertEqual(findit_for_crash.FindItForCrash(
|
| - Stacktrace(), regression_deps_rolls, {}, 7), [])
|
| + self.mock(chromium_deps, 'GetDEPSRollsDict', lambda *_: regression_deps_rolls)
|
| + self.mock(chromium_deps, 'GetChromeDependency', lambda *_: {})
|
| + report = CrashReport(None, None, None, Stacktrace(), None)
|
| + self.assertEqual(changelist_classifier.ChangelistClassifier(7)(report), [])
|
|
|