| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 import os | 5 import os |
| 6 import re | 6 import re |
| 7 import shutil | 7 import shutil |
| 8 import sys | 8 import sys |
| 9 import unittest | 9 import unittest |
| 10 | 10 |
| (...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 423 | 423 |
| 424 def testGetCommitPositionForWebKit(self): | 424 def testGetCommitPositionForWebKit(self): |
| 425 bisect_instance = _GetBisectPerformanceMetricsInstance(DEFAULT_OPTIONS) | 425 bisect_instance = _GetBisectPerformanceMetricsInstance(DEFAULT_OPTIONS) |
| 426 wk_rev = 'a94d028e0f2c77f159b3dac95eb90c3b4cf48c61' | 426 wk_rev = 'a94d028e0f2c77f159b3dac95eb90c3b4cf48c61' |
| 427 depot_path = os.path.join(bisect_instance.src_cwd, 'third_party', 'WebKit') | 427 depot_path = os.path.join(bisect_instance.src_cwd, 'third_party', 'WebKit') |
| 428 self.assertEqual( | 428 self.assertEqual( |
| 429 181660, source_control.GetCommitPosition(wk_rev, depot_path)) | 429 181660, source_control.GetCommitPosition(wk_rev, depot_path)) |
| 430 | 430 |
| 431 def testGetCommitPositionForSkia(self): | 431 def testGetCommitPositionForSkia(self): |
| 432 bisect_instance = _GetBisectPerformanceMetricsInstance(DEFAULT_OPTIONS) | 432 bisect_instance = _GetBisectPerformanceMetricsInstance(DEFAULT_OPTIONS) |
| 433 skia_rev = 'a94d028e0f2c77f159b3dac95eb90c3b4cf48c61' | 433 skia_rev = 'a94d028eCheckAbortsEarly0f2c77f159b3dac95eb90c3b4cf48c61' |
| 434 depot_path = os.path.join(bisect_instance.src_cwd, 'third_party', 'skia') | 434 depot_path = os.path.join(bisect_instance.src_cwd, 'third_party', 'skia') |
| 435 # Skia doesn't use commit positions, and GetCommitPosition should | 435 # Skia doesn't use commit positions, and GetCommitPosition should |
| 436 # return None for repos that don't use commit positions. | 436 # return None for repos that don't use commit positions. |
| 437 self.assertIsNone(source_control.GetCommitPosition(skia_rev, depot_path)) | 437 self.assertIsNone(source_control.GetCommitPosition(skia_rev, depot_path)) |
| 438 | 438 |
| 439 def testUpdateDepsContent(self): | 439 def testUpdateDepsContent(self): |
| 440 bisect_instance = _GetBisectPerformanceMetricsInstance(DEFAULT_OPTIONS) | 440 bisect_instance = _GetBisectPerformanceMetricsInstance(DEFAULT_OPTIONS) |
| 441 deps_file = 'DEPS' | 441 deps_file = 'DEPS' |
| 442 # We are intentionally reading DEPS file contents instead of string literal | 442 # We are intentionally reading DEPS file contents instead of string literal |
| 443 # with few lines from DEPS because to check if the format we are expecting | 443 # with few lines from DEPS because to check if the format we are expecting |
| (...skipping 30 matching lines...) Expand all Loading... |
| 474 | 474 |
| 475 @mock.patch('bisect_utils.RunGit') | 475 @mock.patch('bisect_utils.RunGit') |
| 476 def testSyncToRevisionForWebKit(self, mock_RunGit): | 476 def testSyncToRevisionForWebKit(self, mock_RunGit): |
| 477 bisect_instance = _GetBisectPerformanceMetricsInstance(DEFAULT_OPTIONS) | 477 bisect_instance = _GetBisectPerformanceMetricsInstance(DEFAULT_OPTIONS) |
| 478 mock_RunGit.return_value = None, None | 478 mock_RunGit.return_value = None, None |
| 479 bisect_instance._SyncRevision( | 479 bisect_instance._SyncRevision( |
| 480 'webkit', 'a94d028e0f2c77f159b3dac95eb90c3b4cf48c61' , None) | 480 'webkit', 'a94d028e0f2c77f159b3dac95eb90c3b4cf48c61' , None) |
| 481 expected_params = ['checkout', 'a94d028e0f2c77f159b3dac95eb90c3b4cf48c61'] | 481 expected_params = ['checkout', 'a94d028e0f2c77f159b3dac95eb90c3b4cf48c61'] |
| 482 mock_RunGit.assert_called_with(expected_params) | 482 mock_RunGit.assert_called_with(expected_params) |
| 483 | 483 |
| 484 def testTryJobSvnRepo_PerfBuilderType_ReturnsRepoUrl(self): |
| 485 self.assertEqual(bisect_perf_regression.PERF_SVN_REPO_URL, |
| 486 bisect_perf_regression._TryJobSvnRepo(fetch_build.PERF_BUILDER)) |
| 487 |
| 488 def testTryJobSvnRepo_FullBuilderType_ReturnsRepoUrl(self): |
| 489 self.assertEqual(bisect_perf_regression.FULL_SVN_REPO_URL, |
| 490 bisect_perf_regression._TryJobSvnRepo(fetch_build.FULL_BUILDER)) |
| 491 |
| 492 def testTryJobSvnRepo_WithUnknownBuilderType_ThrowsError(self): |
| 493 with self.assertRaises(NotImplementedError): |
| 494 bisect_perf_regression._TryJobSvnRepo('foo') |
| 495 |
| 496 def _CheckIsDownloadable(self, depot, target_platform='chromium', |
| 497 builder_type='perf'): |
| 498 opts = dict(DEFAULT_OPTIONS) |
| 499 opts.update({'target_platform': target_platform, |
| 500 'builder_type': builder_type}) |
| 501 bisect_instance = _GetBisectPerformanceMetricsInstance(opts) |
| 502 return bisect_instance.IsDownloadable(depot) |
| 503 |
| 504 def testIsDownloadable_ChromiumDepot_ReturnsTrue(self): |
| 505 self.assertTrue(self._CheckIsDownloadable(depot='chromium')) |
| 506 |
| 507 def testIsDownloadable_DEPSDepot_ReturnsTrue(self): |
| 508 self.assertTrue(self._CheckIsDownloadable(depot='v8')) |
| 509 |
| 510 def testIsDownloadable_AndroidChromeDepot_ReturnsTrue(self): |
| 511 self.assertTrue(self._CheckIsDownloadable( |
| 512 depot='android-chrome', target_platform='android-chrome')) |
| 513 |
| 514 def testIsDownloadable_AndroidChromeWithDEPSChromium_ReturnsFalse(self): |
| 515 self.assertFalse(self._CheckIsDownloadable( |
| 516 depot='chromium', target_platform='android-chrome')) |
| 517 |
| 518 def testIsDownloadable_AndroidChromeWithDEPSV8_ReturnsFalse(self): |
| 519 self.assertFalse(self._CheckIsDownloadable( |
| 520 depot='v8', target_platform='android-chrome')) |
| 521 |
| 522 def testIsDownloadable_NoBuilderType_ReturnsFalse(self): |
| 523 self.assertFalse( |
| 524 self._CheckIsDownloadable(depot='chromium', builder_type='')) |
| 525 |
| 484 | 526 |
| 485 class DepotDirectoryRegistryTest(unittest.TestCase): | 527 class DepotDirectoryRegistryTest(unittest.TestCase): |
| 486 | 528 |
| 487 def setUp(self): | 529 def setUp(self): |
| 488 self.old_chdir = os.chdir | 530 self.old_chdir = os.chdir |
| 489 os.chdir = self.mockChdir | 531 os.chdir = self.mockChdir |
| 490 self.old_depot_names = bisect_utils.DEPOT_NAMES | 532 self.old_depot_names = bisect_utils.DEPOT_NAMES |
| 491 bisect_utils.DEPOT_NAMES = ['mock_depot'] | 533 bisect_utils.DEPOT_NAMES = ['mock_depot'] |
| 492 self.old_depot_deps_name = bisect_utils.DEPOT_DEPS_NAME | 534 self.old_depot_deps_name = bisect_utils.DEPOT_DEPS_NAME |
| 493 bisect_utils.DEPOT_DEPS_NAME = {'mock_depot': {'src': 'src/foo'}} | 535 bisect_utils.DEPOT_DEPS_NAME = {'mock_depot': {'src': 'src/foo'}} |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 664 ], (None, 0)), | 706 ], (None, 0)), |
| 665 ] | 707 ] |
| 666 self._SetupRunGitMock(try_cmd) | 708 self._SetupRunGitMock(try_cmd) |
| 667 bisect_perf_regression._StartBuilderTryJob( | 709 bisect_perf_regression._StartBuilderTryJob( |
| 668 fetch_build.PERF_BUILDER, git_revision, bot_name, bisect_job_name, | 710 fetch_build.PERF_BUILDER, git_revision, bot_name, bisect_job_name, |
| 669 patch) | 711 patch) |
| 670 | 712 |
| 671 | 713 |
| 672 if __name__ == '__main__': | 714 if __name__ == '__main__': |
| 673 unittest.main() | 715 unittest.main() |
| OLD | NEW |