| 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 collections import defaultdict | 5 from collections import defaultdict | 
| 6 import copy | 6 import copy | 
| 7 | 7 | 
| 8 from common.dependency import Dependency | 8 from common.dependency import Dependency | 
| 9 from common.dependency import DependencyRoll | 9 from common.dependency import DependencyRoll | 
| 10 from common import chrome_dependency_fetcher | 10 from common import chrome_dependency_fetcher | 
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 111 # allowing us to clean up the tests here. | 111 # allowing us to clean up the tests here. | 
| 112 | 112 | 
| 113 DUMMY_CALLSTACKS = [CallStack(0, [], | 113 DUMMY_CALLSTACKS = [CallStack(0, [], | 
| 114                               CallStackFormatType.DEFAULT, LanguageType.CPP), | 114                               CallStackFormatType.DEFAULT, LanguageType.CPP), | 
| 115                     CallStack(1, [], | 115                     CallStack(1, [], | 
| 116                               CallStackFormatType.DEFAULT, LanguageType.CPP)] | 116                               CallStackFormatType.DEFAULT, LanguageType.CPP)] | 
| 117 DUMMY_REPORT = CrashReport(None, None, None, Stacktrace(DUMMY_CALLSTACKS, | 117 DUMMY_REPORT = CrashReport(None, None, None, Stacktrace(DUMMY_CALLSTACKS, | 
| 118                                                         DUMMY_CALLSTACKS[0]), | 118                                                         DUMMY_CALLSTACKS[0]), | 
| 119                            (None, None)) | 119                            (None, None)) | 
| 120 | 120 | 
|  | 121 | 
| 121 class ChangelistClassifierTest(CrashTestSuite): | 122 class ChangelistClassifierTest(CrashTestSuite): | 
| 122 | 123 | 
| 123   def setUp(self): | 124   def setUp(self): | 
| 124     super(ChangelistClassifierTest, self).setUp() | 125     super(ChangelistClassifierTest, self).setUp() | 
|  | 126 | 
|  | 127     repository = GitilesRepository(self.GetMockHttpClient()) | 
|  | 128 | 
|  | 129     def MutateTheRepo(dep_url): # pragma: no cover | 
|  | 130       """A factory function for returning ``Repository`` objects. | 
|  | 131 | 
|  | 132       The current definition captures the functionality of before | 
|  | 133       we actored out this factory method. That is, it's not really a | 
|  | 134       "factory" but rather mutates the main repo object in place. In | 
|  | 135       the future this should be changed to do the right thing instead. | 
|  | 136       """ | 
|  | 137       repository.repo_url = dep_url | 
|  | 138       return repository | 
|  | 139 | 
| 125     self.changelist_classifier = changelist_classifier.ChangelistClassifier( | 140     self.changelist_classifier = changelist_classifier.ChangelistClassifier( | 
| 126         GitilesRepository(self.GetMockHttpClient()), 7) | 141         repository, MutateTheRepo, 7) | 
| 127 | 142 | 
| 128   def testSkipAddedAndDeletedRegressionRolls(self): | 143   def testSkipAddedAndDeletedRegressionRolls(self): | 
| 129     self.mock(chrome_dependency_fetcher.ChromeDependencyFetcher, | 144     self.mock(chrome_dependency_fetcher.ChromeDependencyFetcher, | 
| 130               'GetDependency', lambda *_: {}) | 145               'GetDependency', lambda *_: {}) | 
| 131     dep_rolls = { | 146     dep_rolls = { | 
| 132         'src/dep': DependencyRoll('src/dep1', 'https://url_dep1', None, '9'), | 147         'src/dep': DependencyRoll('src/dep1', 'https://url_dep1', None, '9'), | 
| 133         'src/': DependencyRoll('src/', ('https://chromium.googlesource.com/' | 148         'src/': DependencyRoll('src/', ('https://chromium.googlesource.com/' | 
| 134                                         'chromium/src.git'), '4', '5') | 149                                         'chromium/src.git'), '4', '5') | 
| 135     } | 150     } | 
| 136     self.mock(chrome_dependency_fetcher.ChromeDependencyFetcher, | 151     self.mock(chrome_dependency_fetcher.ChromeDependencyFetcher, | 
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 305         'project_path': 'src/', | 320         'project_path': 'src/', | 
| 306         'author': 'r@chromium.org', | 321         'author': 'r@chromium.org', | 
| 307         'time': 'Thu Mar 31 21:24:43 2016', | 322         'time': 'Thu Mar 31 21:24:43 2016', | 
| 308         'reasons': None, | 323         'reasons': None, | 
| 309         'confidence': None, | 324         'confidence': None, | 
| 310         'changed_files': None | 325         'changed_files': None | 
| 311     }] | 326     }] | 
| 312 | 327 | 
| 313     suspects = changelist_classifier.FindSuspects( | 328     suspects = changelist_classifier.FindSuspects( | 
| 314         dep_file_to_changelogs, dep_file_to_stack_infos, stack_deps, | 329         dep_file_to_changelogs, dep_file_to_stack_infos, stack_deps, | 
| 315         GitilesRepository(self.GetMockHttpClient())) | 330         lambda repo_url: GitilesRepository(self.GetMockHttpClient(), repo_url)) | 
| 316     self.assertListEqual([suspect.ToDict() for suspect in suspects], | 331     self.assertListEqual([suspect.ToDict() for suspect in suspects], | 
| 317                          expected_suspects) | 332                          expected_suspects) | 
| 318 | 333 | 
| 319   # TODO(http://crbug.com/659346): why do these mocks give coverage | 334   # TODO(http://crbug.com/659346): why do these mocks give coverage | 
| 320   # failures? That's almost surely hiding a bug in the tests themselves. | 335   # failures? That's almost surely hiding a bug in the tests themselves. | 
| 321   def testFindItForCrashNoRegressionRange(self): # pragma: no cover | 336   def testFindItForCrashNoRegressionRange(self): # pragma: no cover | 
| 322     self.mock(chrome_dependency_fetcher.ChromeDependencyFetcher, | 337     self.mock(chrome_dependency_fetcher.ChromeDependencyFetcher, | 
| 323         'GetDependencyRollsDict', lambda *_: {}) | 338         'GetDependencyRollsDict', lambda *_: {}) | 
| 324     self.mock(chrome_dependency_fetcher.ChromeDependencyFetcher, | 339     self.mock(chrome_dependency_fetcher.ChromeDependencyFetcher, | 
| 325         'GetDependency', lambda *_: {}) | 340         'GetDependency', lambda *_: {}) | 
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 482       return [suspect1, suspect2] | 497       return [suspect1, suspect2] | 
| 483 | 498 | 
| 484     self.mock(changelist_classifier, 'FindSuspects', _MockFindSuspects) | 499     self.mock(changelist_classifier, 'FindSuspects', _MockFindSuspects) | 
| 485     self.mock(chrome_dependency_fetcher.ChromeDependencyFetcher, | 500     self.mock(chrome_dependency_fetcher.ChromeDependencyFetcher, | 
| 486         'GetDependencyRollsDict', | 501         'GetDependencyRollsDict', | 
| 487         lambda *_: {'src/': DependencyRoll('src/', 'https://repo', '1', '2')}) | 502         lambda *_: {'src/': DependencyRoll('src/', 'https://repo', '1', '2')}) | 
| 488     self.mock(chrome_dependency_fetcher.ChromeDependencyFetcher, | 503     self.mock(chrome_dependency_fetcher.ChromeDependencyFetcher, | 
| 489         'GetDependency', lambda *_: {}) | 504         'GetDependency', lambda *_: {}) | 
| 490 | 505 | 
| 491     self.assertListEqual(self.changelist_classifier(DUMMY_REPORT), []) | 506     self.assertListEqual(self.changelist_classifier(DUMMY_REPORT), []) | 
| OLD | NEW | 
|---|