| 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 chromium_deps | 5 from common import chromium_deps |
| 6 from common.dependency import DependencyRoll | 6 from common.dependency import DependencyRoll |
| 7 from crash import detect_regression_range | 7 from crash import detect_regression_range |
| 8 from crash import fracas | 8 from crash import fracas |
| 9 from crash import fracas_parser | 9 from crash import fracas_parser |
| 10 from crash import findit_for_crash | 10 from crash import findit_for_crash |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 | 51 |
| 52 def _MockDetectRegressionRange(historic): | 52 def _MockDetectRegressionRange(historic): |
| 53 if historic: | 53 if historic: |
| 54 return '50.0.1233.0', '50.0.1234.0' | 54 return '50.0.1233.0', '50.0.1234.0' |
| 55 | 55 |
| 56 return None | 56 return None |
| 57 | 57 |
| 58 def _MockGetDEPSRollsDict(*_): | 58 def _MockGetDEPSRollsDict(*_): |
| 59 return {'src/': DependencyRoll('src/', 'https://repo', '1', '2')} | 59 return {'src/': DependencyRoll('src/', 'https://repo', '1', '2')} |
| 60 | 60 |
| 61 dummy_match_result = MatchResult(self.GetDummyChangeLog(), 'src/') |
| 61 def _MockFindItForCrash(*args): | 62 def _MockFindItForCrash(*args): |
| 62 regression_deps_rolls = args[1] | 63 regression_deps_rolls = args[1] |
| 63 if regression_deps_rolls: | 64 if regression_deps_rolls: |
| 64 return ['DummyResultObject'] | 65 return [dummy_match_result] |
| 65 | 66 |
| 66 return [] | 67 return [] |
| 67 | 68 |
| 68 def _MockComponentClassify(*_): | 69 def _MockComponentClassify(*_): |
| 69 return [] | 70 return [] |
| 70 | 71 |
| 71 def _MockProjectClassify(*_): | 72 def _MockProjectClassify(*_): |
| 72 return '' | 73 return '' |
| 73 | 74 |
| 74 self.mock(chromium_deps, 'GetChromeDependency', _MockGetChromeDependency) | 75 self.mock(chromium_deps, 'GetChromeDependency', _MockGetChromeDependency) |
| 75 self.mock(fracas_parser.FracasParser, 'Parse', _MockParse) | 76 self.mock(fracas_parser.FracasParser, 'Parse', _MockParse) |
| 76 self.mock(detect_regression_range, 'DetectRegressionRange', | 77 self.mock(detect_regression_range, 'DetectRegressionRange', |
| 77 _MockDetectRegressionRange) | 78 _MockDetectRegressionRange) |
| 78 self.mock(chromium_deps, 'GetDEPSRollsDict', _MockGetDEPSRollsDict) | 79 self.mock(chromium_deps, 'GetDEPSRollsDict', _MockGetDEPSRollsDict) |
| 79 self.mock(findit_for_crash, 'FindItForCrash', _MockFindItForCrash) | 80 self.mock(findit_for_crash, 'FindItForCrash', _MockFindItForCrash) |
| 80 | 81 |
| 81 self.mock(ComponentClassifier, 'Classify', _MockComponentClassify) | 82 self.mock(ComponentClassifier, 'Classify', _MockComponentClassify) |
| 82 self.mock(ProjectClassifier, 'Classify', _MockProjectClassify) | 83 self.mock(ProjectClassifier, 'Classify', _MockProjectClassify) |
| 83 | 84 |
| 84 expected_results = {'found': False} | 85 expected_results = {'found': False} |
| 85 expected_tag = {'found_suspects': False} | 86 expected_tag = {'found_suspects': False} |
| 86 | 87 |
| 87 results, tag = fracas.FindCulpritForChromeCrash( | 88 results, tag = fracas.FindCulpritForChromeCrash( |
| 88 'signature', 'win', 'frame1\nframe2', '50.0.1234.0', | 89 'signature', 'win', 'frame1\nframe2', '50.0.1234.0', |
| 89 [{'chrome_version': '50.0.1234.0', 'cpm': 0.6}]) | 90 [{'chrome_version': '50.0.1234.0', 'cpm': 0.6}]) |
| 90 | 91 |
| 91 expected_results = { | 92 expected_results = { |
| 92 'found': True, | 93 'found': True, |
| 94 'regression_range': ('50.0.1233.0', '50.0.1234.0'), |
| 93 'suspected_project': '', | 95 'suspected_project': '', |
| 94 'suspected_components': [], | 96 'suspected_components': [], |
| 95 'suspected_cls': ['DummyResultObject'], | 97 'suspected_cls': [dummy_match_result.ToDict()], |
| 96 'regression_range': ('50.0.1233.0', '50.0.1234.0') | |
| 97 } | 98 } |
| 98 expected_tag = { | 99 expected_tag = { |
| 99 'found_suspects': True, | 100 'found_suspects': True, |
| 100 'has_regression_range': True, | 101 'has_regression_range': True, |
| 101 'solution': 'core_algorithm', | 102 'solution': 'core_algorithm', |
| 102 } | 103 } |
| 103 | 104 |
| 104 self.assertEqual(expected_results, results) | 105 self.assertEqual(expected_results, results) |
| 105 self.assertEqual(expected_tag, tag) | 106 self.assertEqual(expected_tag, tag) |
| 106 | 107 |
| 107 results, tag = fracas.FindCulpritForChromeCrash( | 108 results, tag = fracas.FindCulpritForChromeCrash( |
| 108 'signature', 'win', 'frame1\nframe2', '50.0.1234.0', | 109 'signature', 'win', 'frame1\nframe2', '50.0.1234.0', |
| 109 []) | 110 []) |
| 110 | 111 |
| 111 expected_results = { | 112 expected_results = { |
| 112 'found': False, | 113 'found': False, |
| 114 'regression_range': None, |
| 113 'suspected_project': '', | 115 'suspected_project': '', |
| 114 'suspected_components': [], | 116 'suspected_components': [], |
| 115 'suspected_cls': [], | 117 'suspected_cls': [], |
| 116 'regression_range': None | |
| 117 } | 118 } |
| 118 expected_tag = { | 119 expected_tag = { |
| 119 'found_suspects': False, | 120 'found_suspects': False, |
| 120 'has_regression_range': False, | 121 'has_regression_range': False, |
| 121 'solution': 'core_algorithm', | 122 'solution': 'core_algorithm', |
| 122 } | 123 } |
| 123 | 124 |
| 124 self.assertEqual(expected_results, results) | 125 self.assertEqual(expected_results, results) |
| 125 self.assertEqual(expected_tag, tag) | 126 self.assertEqual(expected_tag, tag) |
| OLD | NEW |