| OLD | NEW |
| 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 import chrome_dependency_fetcher | 5 from common import chrome_dependency_fetcher |
| 6 from common import git_repository | |
| 7 from common.dependency import DependencyRoll | 6 from common.dependency import DependencyRoll |
| 8 from common.http_client_appengine import HttpClientAppengine | 7 from common.http_client_appengine import HttpClientAppengine |
| 9 from crash import chromecrash_parser | 8 from crash import chromecrash_parser |
| 10 from crash import detect_regression_range | 9 from crash import detect_regression_range |
| 11 from crash import findit_for_chromecrash | 10 from crash import findit_for_chromecrash |
| 12 from crash.changelist_classifier import ChangelistClassifier | 11 from crash.changelist_classifier import ChangelistClassifier |
| 13 from crash.chromecrash_parser import ChromeCrashParser | 12 from crash.chromecrash_parser import ChromeCrashParser |
| 14 from crash.component_classifier import ComponentClassifier | 13 from crash.component_classifier import ComponentClassifier |
| 15 from crash.crash_report import CrashReport | 14 from crash.crash_report import CrashReport |
| 16 from crash.culprit import Culprit | 15 from crash.culprit import Culprit |
| 17 from crash.culprit import NullCulprit | 16 from crash.culprit import NullCulprit |
| 18 from crash.findit_for_chromecrash import FinditForChromeCrash | 17 from crash.findit_for_chromecrash import FinditForChromeCrash |
| 19 from crash.findit_for_chromecrash import FinditForFracas | 18 from crash.findit_for_chromecrash import FinditForFracas |
| 20 from crash.findit import Findit | 19 from crash.findit import Findit |
| 21 from crash.project_classifier import ProjectClassifier | 20 from crash.project_classifier import ProjectClassifier |
| 22 from crash.results import MatchResult | 21 from crash.results import MatchResult |
| 23 from crash.stacktrace import CallStack | 22 from crash.stacktrace import CallStack |
| 24 from crash.stacktrace import Stacktrace | 23 from crash.stacktrace import Stacktrace |
| 25 from crash.test.crash_pipeline_test import DummyCrashData | 24 from crash.test.crash_pipeline_test import DummyCrashData |
| 26 from crash.test.crash_testcase import CrashTestCase | 25 from crash.test.crash_testcase import CrashTestCase |
| 27 from crash.type_enums import CrashClient | 26 from crash.type_enums import CrashClient |
| 27 from lib.gitiles import gitiles_repository |
| 28 from model import analysis_status | 28 from model import analysis_status |
| 29 from model.crash.crash_analysis import CrashAnalysis | 29 from model.crash.crash_analysis import CrashAnalysis |
| 30 from model.crash.fracas_crash_analysis import FracasCrashAnalysis | 30 from model.crash.fracas_crash_analysis import FracasCrashAnalysis |
| 31 | 31 |
| 32 # In production we'd use CrashWrapperPipeline. And that'd work fine here, | 32 # In production we'd use CrashWrapperPipeline. And that'd work fine here, |
| 33 # since we never actually call the method that uses it. But just to be | 33 # since we never actually call the method that uses it. But just to be |
| 34 # absolutely sure we don't go over the wire due to some mocking failure, | 34 # absolutely sure we don't go over the wire due to some mocking failure, |
| 35 # we'll use this dummy class instead. (In fact, since it's never used, | 35 # we'll use this dummy class instead. (In fact, since it's never used, |
| 36 # we don't even need to give a real class; |None| works just fine.) | 36 # we don't even need to give a real class; |None| works just fine.) |
| 37 MOCK_PIPELINE_CLS = None | 37 MOCK_PIPELINE_CLS = None |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 return {} | 70 return {} |
| 71 | 71 |
| 72 def _FinditForFracas(): | 72 def _FinditForFracas(): |
| 73 """A helper to pass in the standard pipeline class.""" | 73 """A helper to pass in the standard pipeline class.""" |
| 74 return FinditForFracas(MOCK_REPOSITORY, MOCK_PIPELINE_CLS) | 74 return FinditForFracas(MOCK_REPOSITORY, MOCK_PIPELINE_CLS) |
| 75 | 75 |
| 76 | 76 |
| 77 class FinditForChromeCrashTest(CrashTestCase): | 77 class FinditForChromeCrashTest(CrashTestCase): |
| 78 | 78 |
| 79 chrome_dep_fetcher = chrome_dependency_fetcher.ChromeDependencyFetcher( | 79 chrome_dep_fetcher = chrome_dependency_fetcher.ChromeDependencyFetcher( |
| 80 git_repository.GitRepository(http_client=HttpClientAppengine())) | 80 gitiles_repository.GitilesRepository(http_client=HttpClientAppengine())) |
| 81 | 81 |
| 82 # TODO(wrengr): what was the purpose of this test? As written it's | 82 # TODO(wrengr): what was the purpose of this test? As written it's |
| 83 # just testing that mocking works. I'm guessing it was to check that | 83 # just testing that mocking works. I'm guessing it was to check that |
| 84 # we fail when the analysis is for the wrong client_id; but if so, | 84 # we fail when the analysis is for the wrong client_id; but if so, |
| 85 # then we shouldn't need to mock FindCulprit... | 85 # then we shouldn't need to mock FindCulprit... |
| 86 def testFindCulprit(self): | 86 def testFindCulprit(self): |
| 87 self.mock(FinditForChromeCrash, 'FindCulprit', | 87 self.mock(FinditForChromeCrash, 'FindCulprit', |
| 88 lambda self, *_: NullCulprit()) | 88 lambda self, *_: NullCulprit()) |
| 89 | 89 |
| 90 # TODO(wrengr): would be less fragile to call | 90 # TODO(wrengr): would be less fragile to call |
| 91 # FinditForFracas.CreateAnalysis instead; though if I'm right about | 91 # FinditForFracas.CreateAnalysis instead; though if I'm right about |
| 92 # the original purpose of this test, then this is one of the few | 92 # the original purpose of this test, then this is one of the few |
| 93 # places where calling FracasCrashAnalysis directly would actually | 93 # places where calling FracasCrashAnalysis directly would actually |
| 94 # make sense. | 94 # make sense. |
| 95 analysis = FracasCrashAnalysis.Create({'signature': 'sig'}) | 95 analysis = FracasCrashAnalysis.Create({'signature': 'sig'}) |
| 96 # TODO(wrengr): shouldn't FracasCrashAnalysis.Create already have set | 96 # TODO(wrengr): shouldn't FracasCrashAnalysis.Create already have set |
| 97 # the client_id? | 97 # the client_id? |
| 98 analysis.client_id = CrashClient.FRACAS | 98 analysis.client_id = CrashClient.FRACAS |
| 99 | 99 |
| 100 findit_client = _FinditForChromeCrash( | 100 findit_client = _FinditForChromeCrash( |
| 101 git_repository.GitRepository(http_client=HttpClientAppengine())) | 101 gitiles_repository.GitilesRepository(http_client=HttpClientAppengine())) |
| 102 result, tags = findit_client.FindCulprit(analysis).ToDicts() | 102 result, tags = findit_client.FindCulprit(analysis).ToDicts() |
| 103 # TODO(wrengr): just test for the NullCulprit directly; instead of | 103 # TODO(wrengr): just test for the NullCulprit directly; instead of |
| 104 # going through |ToDicts|. | 104 # going through |ToDicts|. |
| 105 expected_result, expected_tags = NullCulprit().ToDicts() | 105 expected_result, expected_tags = NullCulprit().ToDicts() |
| 106 self.assertDictEqual(result, expected_result) | 106 self.assertDictEqual(result, expected_result) |
| 107 self.assertDictEqual(tags, expected_tags) | 107 self.assertDictEqual(tags, expected_tags) |
| 108 | 108 |
| 109 | 109 |
| 110 class FinditForFracasTest(CrashTestCase): | 110 class FinditForFracasTest(CrashTestCase): |
| 111 | 111 |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 expected_tag = { | 309 expected_tag = { |
| 310 'found_suspects': False, | 310 'found_suspects': False, |
| 311 'found_project': False, | 311 'found_project': False, |
| 312 'found_components': False, | 312 'found_components': False, |
| 313 'has_regression_range': False, | 313 'has_regression_range': False, |
| 314 'solution': 'core_algorithm', | 314 'solution': 'core_algorithm', |
| 315 } | 315 } |
| 316 | 316 |
| 317 self.assertDictEqual(expected_results, results) | 317 self.assertDictEqual(expected_results, results) |
| 318 self.assertDictEqual(expected_tag, tag) | 318 self.assertDictEqual(expected_tag, tag) |
| OLD | NEW |