| 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 |
| 11 SRC = os.path.join(os.path.dirname(__file__), os.path.pardir, os.path.pardir) | 11 SRC = os.path.join(os.path.dirname(__file__), os.path.pardir, os.path.pardir) |
| 12 sys.path.append(os.path.join(SRC, 'third_party', 'pymock')) | 12 sys.path.append(os.path.join(SRC, 'third_party', 'pymock')) |
| 13 | 13 |
| 14 import bisect_perf_regression | 14 import bisect_perf_regression |
| 15 import bisect_printer | |
| 16 import bisect_utils | 15 import bisect_utils |
| 17 import mock | 16 import mock |
| 18 import source_control | 17 import source_control |
| 19 | 18 |
| 20 | 19 |
| 21 # Regression confidence: 0% | 20 # Regression confidence: 0% |
| 22 CLEAR_NON_REGRESSION = [ | 21 CLEAR_NON_REGRESSION = [ |
| 23 # Mean: 30.223 Std. Dev.: 11.383 | 22 # Mean: 30.223 Std. Dev.: 11.383 |
| 24 [[16.886], [16.909], [16.99], [17.723], [17.952], [18.118], [19.028], | 23 [[16.886], [16.909], [16.99], [17.723], [17.952], [18.118], [19.028], |
| 25 [19.552], [21.954], [38.573], [38.839], [38.965], [40.007], [40.572], | 24 [19.552], [21.954], [38.573], [38.839], [38.965], [40.007], [40.572], |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 | 83 |
| 85 | 84 |
| 86 def _MockRunTests(*args, **kwargs): | 85 def _MockRunTests(*args, **kwargs): |
| 87 _, _ = args, kwargs | 86 _, _ = args, kwargs |
| 88 return _FakeTestResult(_MockResultsGenerator.next()) | 87 return _FakeTestResult(_MockResultsGenerator.next()) |
| 89 | 88 |
| 90 | 89 |
| 91 def _GetBisectPerformanceMetricsInstance(options_dict): | 90 def _GetBisectPerformanceMetricsInstance(options_dict): |
| 92 """Returns an instance of the BisectPerformanceMetrics class.""" | 91 """Returns an instance of the BisectPerformanceMetrics class.""" |
| 93 opts = bisect_perf_regression.BisectOptions.FromDict(options_dict) | 92 opts = bisect_perf_regression.BisectOptions.FromDict(options_dict) |
| 94 return bisect_perf_regression.BisectPerformanceMetrics(opts) | 93 return bisect_perf_regression.BisectPerformanceMetrics(opts, os.getcwd()) |
| 95 | 94 |
| 96 | 95 |
| 97 def _GetExtendedOptions(improvement_dir, fake_first, ignore_confidence=True): | 96 def _GetExtendedOptions(improvement_dir, fake_first, ignore_confidence=True): |
| 98 """Returns the a copy of the default options dict plus some options.""" | 97 """Returns the a copy of the default options dict plus some options.""" |
| 99 result = dict(DEFAULT_OPTIONS) | 98 result = dict(DEFAULT_OPTIONS) |
| 100 result.update({ | 99 result.update({ |
| 101 'improvement_direction': improvement_dir, | 100 'improvement_direction': improvement_dir, |
| 102 'debug_fake_first_test_mean': fake_first, | 101 'debug_fake_first_test_mean': fake_first, |
| 103 'debug_ignore_regression_confidence': ignore_confidence}) | 102 'debug_ignore_regression_confidence': ignore_confidence}) |
| 104 return result | 103 return result |
| (...skipping 12 matching lines...) Expand all Loading... |
| 117 # Disable rmtree to avoid deleting local trees. | 116 # Disable rmtree to avoid deleting local trees. |
| 118 old_rmtree = shutil.rmtree | 117 old_rmtree = shutil.rmtree |
| 119 try: | 118 try: |
| 120 shutil.rmtree = lambda path, onerror: None | 119 shutil.rmtree = lambda path, onerror: None |
| 121 bisect_instance = _GetBisectPerformanceMetricsInstance(options) | 120 bisect_instance = _GetBisectPerformanceMetricsInstance(options) |
| 122 results = bisect_instance.Run( | 121 results = bisect_instance.Run( |
| 123 bisect_instance.opts.command, bisect_instance.opts.bad_revision, | 122 bisect_instance.opts.command, bisect_instance.opts.bad_revision, |
| 124 bisect_instance.opts.good_revision, bisect_instance.opts.metric) | 123 bisect_instance.opts.good_revision, bisect_instance.opts.metric) |
| 125 | 124 |
| 126 if print_results: | 125 if print_results: |
| 127 printer = bisect_printer.BisectPrinter(bisect_instance.opts, | 126 bisect_instance.printer.FormatAndPrintResults(results) |
| 128 bisect_instance.depot_registry) | |
| 129 printer.FormatAndPrintResults(results) | |
| 130 | 127 |
| 131 return results | 128 return results |
| 132 finally: | 129 finally: |
| 133 shutil.rmtree = old_rmtree | 130 shutil.rmtree = old_rmtree |
| 134 | 131 |
| 135 | 132 |
| 136 class BisectPerfRegressionTest(unittest.TestCase): | 133 class BisectPerfRegressionTest(unittest.TestCase): |
| 137 """Test case for other functions and classes in bisect-perf-regression.py.""" | 134 """Test case for other functions and classes in bisect-perf-regression.py.""" |
| 138 | 135 |
| 139 def setUp(self): | 136 def setUp(self): |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 expects is different in some cases, but we want it to work anyway. | 227 expects is different in some cases, but we want it to work anyway. |
| 231 | 228 |
| 232 Specifically, only for android: | 229 Specifically, only for android: |
| 233 After r276628, only android-chrome-shell works. | 230 After r276628, only android-chrome-shell works. |
| 234 Prior to r274857, only android-chromium-testshell works. | 231 Prior to r274857, only android-chromium-testshell works. |
| 235 In the range [274857, 276628], both work. | 232 In the range [274857, 276628], both work. |
| 236 """ | 233 """ |
| 237 bisect_options = bisect_perf_regression.BisectOptions() | 234 bisect_options = bisect_perf_regression.BisectOptions() |
| 238 bisect_options.output_buildbot_annotations = None | 235 bisect_options.output_buildbot_annotations = None |
| 239 bisect_instance = bisect_perf_regression.BisectPerformanceMetrics( | 236 bisect_instance = bisect_perf_regression.BisectPerformanceMetrics( |
| 240 bisect_options) | 237 bisect_options, os.getcwd()) |
| 241 bisect_instance.opts.target_platform = target_platform | 238 bisect_instance.opts.target_platform = target_platform |
| 242 git_revision = source_control.ResolveToRevision( | 239 git_revision = source_control.ResolveToRevision( |
| 243 revision, 'chromium', bisect_utils.DEPOT_DEPS_NAME, 100) | 240 revision, 'chromium', bisect_utils.DEPOT_DEPS_NAME, 100) |
| 244 depot = 'chromium' | 241 depot = 'chromium' |
| 245 command = bisect_instance.GetCompatibleCommand( | 242 command = bisect_instance.GetCompatibleCommand( |
| 246 original_command, git_revision, depot) | 243 original_command, git_revision, depot) |
| 247 self.assertEqual(expected_command, command) | 244 self.assertEqual(expected_command, command) |
| 248 | 245 |
| 249 def testGetCompatibleCommand_ChangeToTestShell(self): | 246 def testGetCompatibleCommand_ChangeToTestShell(self): |
| 250 # For revisions <= r274857, only android-chromium-testshell is used. | 247 # For revisions <= r274857, only android-chromium-testshell is used. |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 os.chdir = self.old_chdir | 393 os.chdir = self.old_chdir |
| 397 bisect_utils.DEPOT_NAMES = self.old_depot_names | 394 bisect_utils.DEPOT_NAMES = self.old_depot_names |
| 398 bisect_utils.DEPOT_DEPS_NAME = self.old_depot_deps_name | 395 bisect_utils.DEPOT_DEPS_NAME = self.old_depot_deps_name |
| 399 | 396 |
| 400 def mockChdir(self, new_dir): | 397 def mockChdir(self, new_dir): |
| 401 self.cur_dir = new_dir | 398 self.cur_dir = new_dir |
| 402 | 399 |
| 403 def testReturnsCorrectResultForChrome(self): | 400 def testReturnsCorrectResultForChrome(self): |
| 404 self.assertEqual(self.registry.GetDepotDir('chromium'), '/mock/src') | 401 self.assertEqual(self.registry.GetDepotDir('chromium'), '/mock/src') |
| 405 | 402 |
| 406 def testReturnsCorrectResultForChromeOS(self): | |
| 407 self.assertEqual(self.registry.GetDepotDir('cros'), '/mock/src/tools/cros') | |
| 408 | |
| 409 def testUsesDepotSpecToInitializeRegistry(self): | 403 def testUsesDepotSpecToInitializeRegistry(self): |
| 410 self.assertEqual(self.registry.GetDepotDir('mock_depot'), '/mock/src/foo') | 404 self.assertEqual(self.registry.GetDepotDir('mock_depot'), '/mock/src/foo') |
| 411 | 405 |
| 412 def testChangedTheDirectory(self): | 406 def testChangedTheDirectory(self): |
| 413 self.registry.ChangeToDepotDir('mock_depot') | 407 self.registry.ChangeToDepotDir('mock_depot') |
| 414 self.assertEqual(self.cur_dir, '/mock/src/foo') | 408 self.assertEqual(self.cur_dir, '/mock/src/foo') |
| 415 | 409 |
| 416 | 410 |
| 417 # The tests below test private functions (W0212). | 411 # The tests below test private functions (W0212). |
| 418 # pylint: disable=W0212 | 412 # pylint: disable=W0212 |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 563 ], (None, 0)), | 557 ], (None, 0)), |
| 564 ] | 558 ] |
| 565 self._SetupRunGitMock(try_cmd) | 559 self._SetupRunGitMock(try_cmd) |
| 566 bisect_perf_regression._BuilderTryjob( | 560 bisect_perf_regression._BuilderTryjob( |
| 567 git_revision, bot_name, bisect_job_name, patch) | 561 git_revision, bot_name, bisect_job_name, patch) |
| 568 | 562 |
| 569 | 563 |
| 570 if __name__ == '__main__': | 564 if __name__ == '__main__': |
| 571 unittest.main() | 565 unittest.main() |
| 572 | 566 |
| OLD | NEW |