diff options
author | qyearsley <qyearsley@chromium.org> | 2015-03-23 13:46:52 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-03-23 20:47:22 +0000 |
commit | 6cd2352b28e8832d1276df86de7ad9fa483de1ad (patch) | |
tree | f0341cb105ac577ce712ca7e47797c11f07ac333 /tools | |
parent | e1dd3a900d5fb58e597256fe0ebb3d0fc7215cf8 (diff) | |
download | chromium_src-6cd2352b28e8832d1276df86de7ad9fa483de1ad.zip chromium_src-6cd2352b28e8832d1276df86de7ad9fa483de1ad.tar.gz chromium_src-6cd2352b28e8832d1276df86de7ad9fa483de1ad.tar.bz2 |
Fix style in tools/auto_bisect.
BUG=
Review URL: https://codereview.chromium.org/1001033004
Cr-Commit-Position: refs/heads/master@{#321839}
Diffstat (limited to 'tools')
-rw-r--r-- | tools/auto_bisect/PRESUBMIT.py | 3 | ||||
-rwxr-xr-x | tools/auto_bisect/bisect_perf_regression.py | 124 | ||||
-rw-r--r-- | tools/auto_bisect/bisect_perf_regression_test.py | 73 | ||||
-rw-r--r-- | tools/auto_bisect/bisect_printer.py | 2 | ||||
-rw-r--r-- | tools/auto_bisect/bisect_results.py | 15 | ||||
-rw-r--r-- | tools/auto_bisect/bisect_results_test.py | 2 | ||||
-rw-r--r-- | tools/auto_bisect/bisect_utils.py | 11 | ||||
-rw-r--r-- | tools/auto_bisect/fetch_build_test.py | 10 | ||||
-rw-r--r-- | tools/auto_bisect/math_utils.py | 1 | ||||
-rw-r--r-- | tools/auto_bisect/query_crbug_test.py | 26 | ||||
-rw-r--r-- | tools/auto_bisect/request_build.py | 23 | ||||
-rw-r--r-- | tools/auto_bisect/source_control.py | 5 | ||||
-rw-r--r-- | tools/auto_bisect/source_control_test.py | 1 |
13 files changed, 156 insertions, 140 deletions
diff --git a/tools/auto_bisect/PRESUBMIT.py b/tools/auto_bisect/PRESUBMIT.py index 1e99787..380cb00 100644 --- a/tools/auto_bisect/PRESUBMIT.py +++ b/tools/auto_bisect/PRESUBMIT.py @@ -18,6 +18,7 @@ CONFIG_FILES = [ os.path.join(os.path.pardir, 'run-perf-test.cfg'), ] + def CheckChangeOnUpload(input_api, output_api): return _CommonChecks(input_api, output_api) @@ -93,7 +94,7 @@ def _RunPyLint(input_api, output_api): 'third_party', 'pymock') disabled_warnings = [ 'relative-import', - ] + ] tests = input_api.canned_checks.GetPylint( input_api, output_api, disabled_warnings=disabled_warnings, extra_paths_list=[telemetry_path, mock_path]) diff --git a/tools/auto_bisect/bisect_perf_regression.py b/tools/auto_bisect/bisect_perf_regression.py index 4e2abc2..ddc0f60 100755 --- a/tools/auto_bisect/bisect_perf_regression.py +++ b/tools/auto_bisect/bisect_perf_regression.py @@ -128,6 +128,7 @@ FULL_SVN_REPO_URL = 'svn://svn.chromium.org/chrome-try/try' ANDROID_CHROME_SVN_REPO_URL = ('svn://svn.chromium.org/chrome-try-internal/' 'try-perf') + class RunGitError(Exception): def __str__(self): @@ -461,11 +462,15 @@ def _GenerateProfileIfNecessary(command_args): path_to_generate = os.path.join('tools', 'perf', 'generate_profile') - if arg_dict.has_key('--profile-dir') and arg_dict.has_key('--browser'): + if '--profile-dir' in arg_dict and '--browser' in arg_dict: profile_path, profile_type = os.path.split(arg_dict['--profile-dir']) - return not bisect_utils.RunProcess(['python', path_to_generate, - '--profile-type-to-generate', profile_type, - '--browser', arg_dict['--browser'], '--output-dir', profile_path]) + return not bisect_utils.RunProcess( + [ + 'python', path_to_generate, + '--profile-type-to-generate', profile_type, + '--browser', arg_dict['--browser'], + '--output-dir', profile_path + ]) return False return True @@ -485,7 +490,7 @@ def _CheckRegressionConfidenceError( known_bad_value: Same as above. Returns: - False if there is no error (i.e. we can be confident there's a regressioni), + False if there is no error (i.e. we can be confident there's a regression), a string containing the details of the lack of confidence otherwise. """ error = False @@ -576,8 +581,8 @@ def _PrepareBisectBranch(parent_branch, new_branch): if output: raise RunGitError('Cannot send a try job with a dirty tree.') - # Create/check out the telemetry-tryjob branch, and edit the configs - # for the tryjob there. + # Create and check out the telemetry-tryjob branch, and edit the configs + # for the try job there. output, returncode = bisect_utils.RunGit(['checkout', '-b', new_branch]) if returncode: raise RunGitError('Failed to checkout branch: %s.' % output) @@ -604,7 +609,7 @@ def _StartBuilderTryJob( # TODO(prasadv, qyearsley): Make this a method of BuildArchive # (which may be renamed to BuilderTryBot or Builder). try: - # Temporary branch for running tryjob. + # Temporary branch for running a try job. _PrepareBisectBranch(BISECT_MASTER_BRANCH, BISECT_TRYJOB_BRANCH) patch_content = '/dev/null' # Create a temporary patch file. @@ -626,7 +631,7 @@ def _StartBuilderTryJob( command_string = ' '.join(['git'] + try_command) if return_code: - raise RunGitError('Could not execute tryjob: %s.\n' + raise RunGitError('Could not execute try job: %s.\n' 'Error: %s' % (command_string, output)) logging.info('Try job successfully submitted.\n TryJob Details: %s\n%s', command_string, output) @@ -747,8 +752,7 @@ class BisectPerformanceMetrics(object): depot_revision = depot_revision.strip('@') logging.warn(depot_name, depot_revision) for cur_name, cur_data in bisect_utils.DEPOT_DEPS_NAME.iteritems(): - if (cur_data.has_key('deps_var') and - cur_data['deps_var'] == depot_name): + if cur_data.get('deps_var') == depot_name: src_name = cur_name results[src_name] = depot_revision break @@ -923,7 +927,7 @@ class BisectPerformanceMetrics(object): 'Error: %s', git_revision, e) return None - # Get the buildbot master url to monitor build status. + # Get the buildbot master URL to monitor build status. buildbot_server_url = fetch_build.GetBuildBotUrl( builder_type=self.opts.builder_type, target_arch=self.opts.target_arch, @@ -1027,8 +1031,8 @@ class BisectPerformanceMetrics(object): return depot == 'android-chrome' else: return (depot == 'chromium' or - 'chromium' in bisect_utils.DEPOT_DEPS_NAME[depot]['from'] or - 'v8' in bisect_utils.DEPOT_DEPS_NAME[depot]['from']) + 'chromium' in bisect_utils.DEPOT_DEPS_NAME[depot]['from'] or + 'v8' in bisect_utils.DEPOT_DEPS_NAME[depot]['from']) return False def UpdateDepsContents(self, deps_contents, depot, git_revision, deps_key): @@ -1362,7 +1366,7 @@ class BisectPerformanceMetrics(object): metric_values.append(return_code) elapsed_minutes = (time.time() - start_time) / 60.0 - time_limit = self.opts.max_time_minutes * test_run_multiplier + time_limit = self.opts.max_time_minutes * test_run_multiplier if elapsed_minutes >= time_limit: break @@ -1442,8 +1446,8 @@ class BisectPerformanceMetrics(object): True if successful. """ if 'android' in self.opts.target_platform: - if not builder.SetupAndroidBuildEnvironment(self.opts, - path_to_src=self.src_cwd): + if not builder.SetupAndroidBuildEnvironment( + self.opts, path_to_src=self.src_cwd): return False return self.RunGClientHooks() @@ -1548,11 +1552,11 @@ class BisectPerformanceMetrics(object): if not external_revisions is None: return (results[0], results[1], external_revisions, - time.time() - after_build_time, after_build_time - - start_build_time) + time.time() - after_build_time, after_build_time - + start_build_time) else: return ('Failed to parse DEPS file for external revisions.', - BUILD_RESULT_FAIL) + BUILD_RESULT_FAIL) def _SyncRevision(self, depot, revision, sync_client): """Syncs depot to particular revision. @@ -1575,7 +1579,7 @@ class BisectPerformanceMetrics(object): # i.e. gclient sync src@<SHA1> if sync_client == 'gclient' and revision: revision = '%s@%s' % (bisect_utils.DEPOT_DEPS_NAME[depot]['src'], - revision) + revision) if depot == 'chromium' and self.opts.target_platform == 'android-chrome': return self._SyncRevisionsForAndroidChrome(revision) @@ -1617,9 +1621,9 @@ class BisectPerformanceMetrics(object): """ if self.opts.bisect_mode == bisect_utils.BISECT_MODE_STD_DEV: dist_to_good_value = abs(current_value['std_dev'] - - known_good_value['std_dev']) + known_good_value['std_dev']) dist_to_bad_value = abs(current_value['std_dev'] - - known_bad_value['std_dev']) + known_bad_value['std_dev']) else: dist_to_good_value = abs(current_value['mean'] - known_good_value['mean']) dist_to_bad_value = abs(current_value['mean'] - known_bad_value['mean']) @@ -1694,8 +1698,8 @@ class BisectPerformanceMetrics(object): bisect_utils.DEPOT_DEPS_NAME, -1, cwd=v8_bleeding_edge_dir) if git_revision: - revision_info = source_control.QueryRevisionInfo(git_revision, - cwd=v8_bleeding_edge_dir) + revision_info = source_control.QueryRevisionInfo( + git_revision, cwd=v8_bleeding_edge_dir) if 'Prepare push to trunk' in revision_info['subject']: return git_revision @@ -1772,10 +1776,16 @@ class BisectPerformanceMetrics(object): v8_branch = 'origin/master' bleeding_edge_branch = 'origin/bleeding_edge' - r1 = self._GetNearestV8BleedingEdgeFromTrunk(min_revision_state.revision, - v8_branch, bleeding_edge_branch, search_forward=True) - r2 = self._GetNearestV8BleedingEdgeFromTrunk(max_revision_state.revision, - v8_branch, bleeding_edge_branch, search_forward=False) + r1 = self._GetNearestV8BleedingEdgeFromTrunk( + min_revision_state.revision, + v8_branch, + bleeding_edge_branch, + search_forward=True) + r2 = self._GetNearestV8BleedingEdgeFromTrunk( + max_revision_state.revision, + v8_branch, + bleeding_edge_branch, + search_forward=False) min_revision_state.external['v8_bleeding_edge'] = r1 max_revision_state.external['v8_bleeding_edge'] = r2 @@ -1803,9 +1813,9 @@ class BisectPerformanceMetrics(object): """ external_depot = None for next_depot in bisect_utils.DEPOT_NAMES: - if bisect_utils.DEPOT_DEPS_NAME[next_depot].has_key('platform'): - if bisect_utils.DEPOT_DEPS_NAME[next_depot]['platform'] != os.name: - continue + if ('platform' in bisect_utils.DEPOT_DEPS_NAME[next_depot] and + bisect_utils.DEPOT_DEPS_NAME[next_depot]['platform'] != os.name): + continue if not (bisect_utils.DEPOT_DEPS_NAME[next_depot]['recurse'] and min_revision_state.depot @@ -1850,7 +1860,7 @@ class BisectPerformanceMetrics(object): # V8 (and possibly others) is merged in periodically. Bisecting # this directory directly won't give much good info. - if bisect_utils.DEPOT_DEPS_NAME[current_depot].has_key('custom_deps'): + if 'custom_deps' in bisect_utils.DEPOT_DEPS_NAME[current_depot]: config_path = os.path.join(self.src_cwd, '..') if bisect_utils.RunGClientAndCreateConfig( self.opts, bisect_utils.DEPOT_DEPS_NAME[current_depot]['custom_deps'], @@ -1869,10 +1879,10 @@ class BisectPerformanceMetrics(object): self.cleanup_commands.append(['mv', 'v8', 'v8_bleeding_edge']) self.cleanup_commands.append(['mv', 'v8.bak', 'v8']) - self.depot_registry.SetDepotDir('v8_bleeding_edge', - os.path.join(self.src_cwd, 'v8')) - self.depot_registry.SetDepotDir('v8', os.path.join(self.src_cwd, - 'v8.bak')) + self.depot_registry.SetDepotDir( + 'v8_bleeding_edge', os.path.join(self.src_cwd, 'v8')) + self.depot_registry.SetDepotDir( + 'v8', os.path.join(self.src_cwd, 'v8.bak')) self.depot_registry.ChangeToDepotDir(current_depot) @@ -1960,17 +1970,22 @@ class BisectPerformanceMetrics(object): # Try looking for a commit that touches the .DEPS.git file in the # next 15 minutes after the DEPS file change. - cmd = ['log', '--format=%H', '-1', - '--before=%d' % (commit_time + 900), '--after=%d' % commit_time, - 'origin/master', '--', bisect_utils.FILE_DEPS_GIT] + cmd = [ + 'log', '--format=%H', '-1', + '--before=%d' % (commit_time + 900), + '--after=%d' % commit_time, + 'origin/master', '--', bisect_utils.FILE_DEPS_GIT + ] output = bisect_utils.CheckRunGit(cmd) output = output.strip() if output: - self.warnings.append('Detected change to DEPS and modified ' + self.warnings.append( + 'Detected change to DEPS and modified ' 'revision range to include change to .DEPS.git') return (output, good_revision) else: - self.warnings.append('Detected change to DEPS but couldn\'t find ' + self.warnings.append( + 'Detected change to DEPS but couldn\'t find ' 'matching change to .DEPS.git') return (bad_revision, good_revision) @@ -2001,8 +2016,8 @@ class BisectPerformanceMetrics(object): """Checks whether a given revision is bisectable. Checks for following: - 1. Non-bisectable revsions for android bots (refer to crbug.com/385324). - 2. Non-bisectable revsions for Windows bots (refer to crbug.com/405274). + 1. Non-bisectable revisions for android bots (refer to crbug.com/385324). + 2. Non-bisectable revisions for Windows bots (refer to crbug.com/405274). Args: good_revision: Known good revision. @@ -2052,7 +2067,7 @@ class BisectPerformanceMetrics(object): metric: The performance metric to monitor. """ run_results_tot, run_results_reverted = self._RevertCulpritCLAndRetest( - results, target_depot, command_to_run, metric) + results, target_depot, command_to_run, metric) results.AddRetestResults(run_results_tot, run_results_reverted) @@ -2061,7 +2076,8 @@ class BisectPerformanceMetrics(object): # Cleanup reverted files if anything is left. _, _, culprit_depot = results.culprit_revisions[0] - bisect_utils.CheckRunGit(['reset', '--hard', 'HEAD'], + bisect_utils.CheckRunGit( + ['reset', '--hard', 'HEAD'], cwd=self.depot_registry.GetDepotDir(culprit_depot)) def _RevertCL(self, culprit_revision, culprit_depot): @@ -2132,7 +2148,8 @@ class BisectPerformanceMetrics(object): head_revision, target_depot, command_to_run, metric, force_build) # Clear the reverted file(s). - bisect_utils.RunGit(['reset', '--hard', 'HEAD'], + bisect_utils.RunGit( + ['reset', '--hard', 'HEAD'], cwd=self.depot_registry.GetDepotDir(culprit_depot)) # Retesting with the reverted CL failed, so bail out of retesting against @@ -2147,7 +2164,8 @@ class BisectPerformanceMetrics(object): return (run_results_tot, run_results_reverted) - def _RunTestWithAnnotations(self, step_text, error_text, head_revision, + def _RunTestWithAnnotations( + self, step_text, error_text, head_revision, target_depot, command_to_run, metric, force_build): """Runs the performance test and outputs start/stop annotations. @@ -2330,8 +2348,11 @@ class BisectPerformanceMetrics(object): known_good_value, known_bad_value) if confidence_error: + # If there is no significant difference between "good" and "bad" + # revision results, then the "bad revision" is considered "good". + # TODO(qyearsley): Remove this if it is not necessary. + bad_revision_state.passed = True self.warnings.append(confidence_error) - bad_revision_state.passed = True # Marking the 'bad' revision as good. return BisectResults(bisect_state, self.depot_registry, self.opts, self.warnings) @@ -2358,7 +2379,8 @@ class BisectPerformanceMetrics(object): # is over. if not external_depot: if current_depot == 'v8': - self.warnings.append('Unfortunately, V8 bisection couldn\'t ' + self.warnings.append( + 'Unfortunately, V8 bisection couldn\'t ' 'continue any further. The script can only bisect into ' 'V8\'s bleeding_edge repository if both the current and ' 'previous revisions in trunk map directly to revisions in ' @@ -2448,7 +2470,6 @@ class BisectPerformanceMetrics(object): self.printer.PrintPartialResults(bisect_state) bisect_utils.OutputAnnotationStepClosed() - self._ConfidenceExtraTestRuns(min_revision_state, max_revision_state, command_to_run, metric) results = BisectResults(bisect_state, self.depot_registry, self.opts, @@ -2812,7 +2833,6 @@ def main(): bisect_test.printer.FormatAndPrintResults(results) return 0 - if opts.extra_src: extra_src = bisect_utils.LoadExtraSrc(opts.extra_src) if not extra_src: diff --git a/tools/auto_bisect/bisect_perf_regression_test.py b/tools/auto_bisect/bisect_perf_regression_test.py index 3060f45..276cdeb 100644 --- a/tools/auto_bisect/bisect_perf_regression_test.py +++ b/tools/auto_bisect/bisect_perf_regression_test.py @@ -70,31 +70,31 @@ CLEAR_REGRESSION = [ MULTIPLE_VALUES = [ [ [18.916, 22.371, 8.527, 5.877, 5.407, 9.476, 8.100, 5.334, - 4.507, 4.842, 8.485, 8.308, 27.490, 4.560, 4.804, 23.068, 17.577, - 17.346, 26.738, 60.330, 32.307, 5.468, 27.803, 27.373, 17.823, - 5.158, 27.439, 5.236, 11.413], + 4.507, 4.842, 8.485, 8.308, 27.490, 4.560, 4.804, 23.068, 17.577, + 17.346, 26.738, 60.330, 32.307, 5.468, 27.803, 27.373, 17.823, + 5.158, 27.439, 5.236, 11.413], [18.999, 22.642, 8.158, 5.995, 5.495, 9.499, 8.092, 5.324, - 4.468, 4.788, 8.248, 7.853, 27.533, 4.410, 4.622, 22.341, 22.313, - 17.072, 26.731, 57.513, 33.001, 5.500, 28.297, 27.277, 26.462, - 5.009, 27.361, 5.130, 10.955] + 4.468, 4.788, 8.248, 7.853, 27.533, 4.410, 4.622, 22.341, 22.313, + 17.072, 26.731, 57.513, 33.001, 5.500, 28.297, 27.277, 26.462, + 5.009, 27.361, 5.130, 10.955] ], [ [18.238, 22.365, 8.555, 5.939, 5.437, 9.463, 7.047, 5.345, 4.517, - 4.796, 8.593, 7.901, 27.499, 4.378, 5.040, 4.904, 4.816, 4.828, - 4.853, 57.363, 34.184, 5.482, 28.190, 27.290, 26.694, 5.099, - 4.905, 5.290, 4.813], + 4.796, 8.593, 7.901, 27.499, 4.378, 5.040, 4.904, 4.816, 4.828, + 4.853, 57.363, 34.184, 5.482, 28.190, 27.290, 26.694, 5.099, + 4.905, 5.290, 4.813], [18.301, 22.522, 8.035, 6.021, 5.565, 9.037, 6.998, 5.321, 4.485, - 4.768, 8.397, 7.865, 27.636, 4.640, 5.015, 4.962, 4.933, 4.977, - 4.961, 60.648, 34.593, 5.538, 28.454, 27.297, 26.490, 5.099, 5, - 5.247, 4.945], + 4.768, 8.397, 7.865, 27.636, 4.640, 5.015, 4.962, 4.933, 4.977, + 4.961, 60.648, 34.593, 5.538, 28.454, 27.297, 26.490, 5.099, 5, + 5.247, 4.945], [18.907, 23.368, 8.100, 6.169, 5.621, 9.971, 8.161, 5.331, 4.513, - 4.837, 8.255, 7.852, 26.209, 4.388, 5.045, 5.029, 5.032, 4.946, - 4.973, 60.334, 33.377, 5.499, 28.275, 27.550, 26.103, 5.108, - 4.951, 5.285, 4.910], + 4.837, 8.255, 7.852, 26.209, 4.388, 5.045, 5.029, 5.032, 4.946, + 4.973, 60.334, 33.377, 5.499, 28.275, 27.550, 26.103, 5.108, + 4.951, 5.285, 4.910], [18.715, 23.748, 8.128, 6.148, 5.691, 9.361, 8.106, 5.334, 4.528, - 4.965, 8.261, 7.851, 27.282, 4.391, 4.949, 4.981, 4.964, 4.935, - 4.933, 60.231, 33.361, 5.489, 28.106, 27.457, 26.648, 5.108, - 4.963, 5.272, 4.954] + 4.965, 8.261, 7.851, 27.282, 4.391, 4.949, 4.981, 4.964, 4.935, + 4.933, 60.231, 33.361, 5.489, 28.106, 27.457, 26.648, 5.108, + 4.963, 5.272, 4.954] ] ] @@ -115,8 +115,7 @@ DEFAULT_OPTIONS = { _MockResultsGenerator = (x for x in []) -def _MockRunTests(*args, **kwargs): - _, _ = args, kwargs +def _MockRunTests(*args, **kwargs): # pylint: disable=unused-argument return _FakeTestResult(_MockResultsGenerator.next()) @@ -379,7 +378,7 @@ class BisectPerfRegressionTest(unittest.TestCase): bisect_class.RunPerformanceTestAndParseResults = _MockRunTests try: - _GenericDryRun(_GetExtendedOptions(0, 0, False)) + dry_run_results = _GenericDryRun(_GetExtendedOptions(0, 0, False)) except StopIteration: # If StopIteration was raised, that means that the next value after # the first two values was requested, so the job was not aborted. @@ -388,23 +387,23 @@ class BisectPerfRegressionTest(unittest.TestCase): bisect_class.RunPerformanceTestAndParseResults = original_run_tests # If the job was aborted, there should be a warning about it. - assert [w for w in results.warnings + assert [w for w in dry_run_results.warnings if 'could not reproduce the regression' in w] return True - def testBisectStopsOnClearUnclearRegression(self): + def testBisectAbortedOnClearNonRegression(self): self.assertTrue(self._CheckAbortsEarly(CLEAR_NON_REGRESSION)) - def testBisectStopsOnClearUnclearRegression(self): + def testBisectNotAborted_AlmostRegression(self): self.assertFalse(self._CheckAbortsEarly(ALMOST_REGRESSION)) - def testBisectStopsOnClearUnclearRegression(self): + def testBisectNotAborted_ClearRegression(self): self.assertFalse(self._CheckAbortsEarly(CLEAR_REGRESSION)) - def testBisectStopsOnClearUnclearRegression(self): + def testBisectNotAborted_BarelyRegression(self): self.assertFalse(self._CheckAbortsEarly(BARELY_REGRESSION)) - def testBisectStopsOnClearUnclearRegression(self): + def testBisectNotAborted_MultipleValues(self): self.assertFalse(self._CheckAbortsEarly(MULTIPLE_VALUES)) def testGetCommitPosition(self): @@ -467,8 +466,8 @@ class BisectPerfRegressionTest(unittest.TestCase): '--force', '--delete_unversioned_trees', '--revision', - 'src@e6db23a037cad47299a94b155b95eebd1ee61a58' - ] + 'src@e6db23a037cad47299a94b155b95eebd1ee61a58', + ] mock_RunGClient.assert_called_with(expected_params, cwd=None) @@ -477,16 +476,18 @@ class BisectPerfRegressionTest(unittest.TestCase): bisect_instance = _GetBisectPerformanceMetricsInstance(DEFAULT_OPTIONS) mock_RunGit.return_value = None, None bisect_instance._SyncRevision( - 'webkit', 'a94d028e0f2c77f159b3dac95eb90c3b4cf48c61' , None) + 'webkit', 'a94d028e0f2c77f159b3dac95eb90c3b4cf48c61', None) expected_params = ['checkout', 'a94d028e0f2c77f159b3dac95eb90c3b4cf48c61'] mock_RunGit.assert_called_with(expected_params) def testTryJobSvnRepo_PerfBuilderType_ReturnsRepoUrl(self): - self.assertEqual(bisect_perf_regression.PERF_SVN_REPO_URL, + self.assertEqual( + bisect_perf_regression.PERF_SVN_REPO_URL, bisect_perf_regression._TryJobSvnRepo(fetch_build.PERF_BUILDER)) def testTryJobSvnRepo_FullBuilderType_ReturnsRepoUrl(self): - self.assertEqual(bisect_perf_regression.FULL_SVN_REPO_URL, + self.assertEqual( + bisect_perf_regression.FULL_SVN_REPO_URL, bisect_perf_regression._TryJobSvnRepo(fetch_build.FULL_BUILDER)) def testTryJobSvnRepo_WithUnknownBuilderType_ThrowsError(self): @@ -672,8 +673,8 @@ class GitTryJobTestCases(unittest.TestCase): '--revision=%s' % git_revision, '--name=%s' % bisect_job_name, '--svn_repo=%s' % bisect_perf_regression.PERF_SVN_REPO_URL, - '--diff=%s' % patch_content - ], (None, 1)), + '--diff=%s' % patch_content], + (None, 1)), ] self._AssertRunGitExceptions( try_cmd, bisect_perf_regression._StartBuilderTryJob, @@ -702,8 +703,8 @@ class GitTryJobTestCases(unittest.TestCase): '--revision=%s' % git_revision, '--name=%s' % bisect_job_name, '--svn_repo=%s' % bisect_perf_regression.PERF_SVN_REPO_URL, - '--diff=%s' % patch_content - ], (None, 0)), + '--diff=%s' % patch_content], + (None, 0)), ] self._SetupRunGitMock(try_cmd) bisect_perf_regression._StartBuilderTryJob( diff --git a/tools/auto_bisect/bisect_printer.py b/tools/auto_bisect/bisect_printer.py index 8aeb066..2786691 100644 --- a/tools/auto_bisect/bisect_printer.py +++ b/tools/auto_bisect/bisect_printer.py @@ -204,7 +204,7 @@ class BisectPrinter(object): @staticmethod def _GetViewVCLinkFromDepotAndHash(git_revision, depot): """Gets link to the repository browser.""" - if depot and bisect_utils.DEPOT_DEPS_NAME[depot].has_key('viewvc'): + if depot and 'viewvc' in bisect_utils.DEPOT_DEPS_NAME[depot]: return bisect_utils.DEPOT_DEPS_NAME[depot]['viewvc'] + git_revision return '' diff --git a/tools/auto_bisect/bisect_results.py b/tools/auto_bisect/bisect_results.py index 07b7806..d4fb541 100644 --- a/tools/auto_bisect/bisect_results.py +++ b/tools/auto_bisect/bisect_results.py @@ -58,7 +58,6 @@ class BisectResults(object): runtime_warnings: A list of warnings from the bisect run. error: Error message. When error is not None, other arguments are ignored. """ - self.error = error self.abort_reason = abort_reason if error is not None or abort_reason is not None: @@ -66,8 +65,8 @@ class BisectResults(object): assert (bisect_state is not None and depot_registry is not None and opts is not None and runtime_warnings is not None), ( - 'Incorrect use of the BisectResults constructor. When error is ' - 'None, all other arguments are required') + 'Incorrect use of the BisectResults constructor. ' + 'When error is None, all other arguments are required.') self.state = bisect_state @@ -113,7 +112,7 @@ class BisectResults(object): return confidence_params = (results_reverted[0]['values'], - results_tot[0]['values']) + results_tot[0]['values']) confidence = BisectResults.ConfidenceScore(*confidence_params) self.retest_results_tot = RevisionState('ToT', 'n/a', 0) @@ -127,7 +126,7 @@ class BisectResults(object): 'Confidence of re-test with reverted CL is not high.' ' Check that the regression hasn\'t already recovered. ' ' There\'s still a chance this is a regression, as performance of' - ' local builds may not match official builds.' ) + ' local builds may not match official builds.') @staticmethod def _GetResultBasedWarnings(culprit_revisions, opts, confidence): @@ -218,8 +217,10 @@ class BisectResults(object): # mean of the current runs, this local regression is in same # direction. prev_greater_than_current = mean_of_prev_runs > mean_of_current_runs - is_same_direction = (prev_greater_than_current if - bad_greater_than_good else not prev_greater_than_current) + if bad_greater_than_good: + is_same_direction = prev_greater_than_current + else: + is_same_direction = not prev_greater_than_current # Only report potential regressions with high confidence. if is_same_direction and confidence > 50: diff --git a/tools/auto_bisect/bisect_results_test.py b/tools/auto_bisect/bisect_results_test.py index 3926d0e..1fc3fe1 100644 --- a/tools/auto_bisect/bisect_results_test.py +++ b/tools/auto_bisect/bisect_results_test.py @@ -235,7 +235,7 @@ class BisectResultsTest(unittest.TestCase): revision_states[2].depot = 'webkit' results = BisectResults(self.mock_bisect_state, self.mock_depot_registry, - self.mock_opts, self.mock_warnings) + self.mock_opts, self.mock_warnings) self.assertEqual(1, len(results.culprit_revisions)) self.assertEqual(('b', {'test': 'b'}, 'chromium'), diff --git a/tools/auto_bisect/bisect_utils.py b/tools/auto_bisect/bisect_utils.py index e2783e3..0d7f506 100644 --- a/tools/auto_bisect/bisect_utils.py +++ b/tools/auto_bisect/bisect_utils.py @@ -325,7 +325,6 @@ def RunGClientAndCreateConfig(opts, custom_deps=None, cwd=None): return return_code - def OnAccessError(func, path, _): """Error handler for shutil.rmtree. @@ -431,7 +430,7 @@ def CheckRunGit(command, cwd=None): Returns: A tuple of the output and return code. """ - (output, return_code) = RunGit(command, cwd=cwd) + output, return_code = RunGit(command, cwd=cwd) assert not return_code, 'An error occurred while running'\ ' "git %s"' % ' '.join(command) @@ -463,8 +462,7 @@ def CreateBisectDirectoryAndSetupDepot(opts, custom_deps): if CheckIfBisectDepotExists(opts): path_to_dir = os.path.join(os.path.abspath(opts.working_directory), BISECT_DIR, 'src') - (output, _) = RunGit(['rev-parse', '--is-inside-work-tree'], - cwd=path_to_dir) + output, _ = RunGit(['rev-parse', '--is-inside-work-tree'], cwd=path_to_dir) if output.strip() == 'true': # Before checking out master, cleanup up any leftover index.lock files. _CleanupPreviousGitRuns(path_to_dir) @@ -515,9 +513,10 @@ def RunProcessAndRetrieveOutput(command, cwd=None): # On Windows, use shell=True to get PATH interpretation. shell = IsWindowsHost() - proc = subprocess.Popen(command, shell=shell, stdout=subprocess.PIPE, + proc = subprocess.Popen( + command, shell=shell, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) - (output, _) = proc.communicate() + output, _ = proc.communicate() if cwd: os.chdir(original_cwd) diff --git a/tools/auto_bisect/fetch_build_test.py b/tools/auto_bisect/fetch_build_test.py index 85c8ff2..4c821cb 100644 --- a/tools/auto_bisect/fetch_build_test.py +++ b/tools/auto_bisect/fetch_build_test.py @@ -71,7 +71,8 @@ class BuildArchiveTest(unittest.TestCase): archive = fetch_build.FullBuildArchive() archive._platform = 'android' self.assertEqual('chromium-android', archive.BucketName()) - self.assertEqual('android_main_rel/full-build-linux_1234567890abcdef.zip', + self.assertEqual( + 'android_main_rel/full-build-linux_1234567890abcdef.zip', archive.FilePath('1234567890abcdef')) def test_FullBuildArchive_Linux_BuilderName(self): @@ -167,13 +168,16 @@ class BuildArchiveTest(unittest.TestCase): self.assertEqual(14400, archive.GetBuilderBuildTime()) def test_GetBuildBotUrl_Perf(self): - self.assertEqual(fetch_build.PERF_TRY_SERVER_URL, + self.assertEqual( + fetch_build.PERF_TRY_SERVER_URL, fetch_build.GetBuildBotUrl(fetch_build.PERF_BUILDER)) def test_GetBuildBotUrl_full(self): - self.assertEqual(fetch_build.LINUX_TRY_SERVER_URL, + self.assertEqual( + fetch_build.LINUX_TRY_SERVER_URL, fetch_build.GetBuildBotUrl(fetch_build.FULL_BUILDER)) + class UnzipTest(unittest.TestCase): def setUp(self): diff --git a/tools/auto_bisect/math_utils.py b/tools/auto_bisect/math_utils.py index dc1c885..eef7f09 100644 --- a/tools/auto_bisect/math_utils.py +++ b/tools/auto_bisect/math_utils.py @@ -136,4 +136,3 @@ def StandardError(values): return 0.0 std_dev = StandardDeviation(values) return std_dev / math.sqrt(len(values)) - diff --git a/tools/auto_bisect/query_crbug_test.py b/tools/auto_bisect/query_crbug_test.py index 40e6fa8..5406487 100644 --- a/tools/auto_bisect/query_crbug_test.py +++ b/tools/auto_bisect/query_crbug_test.py @@ -27,7 +27,7 @@ UNEXPECTED_FORMAT_DATA = CLOSED_ISSUE_DATA.replace('issues$state', 'gibberish') BROKEN_ISSUE_DATA = "\n<HTML><HEAD><TITLE>Not a JSON Doc</TITLE></HEAD></HTML>" -class mockResponse(object): +class MockResponse(object): def __init__(self, result): self._result = result @@ -35,45 +35,45 @@ class mockResponse(object): return self._result -def mockUrlOpen(url): +def MockUrlOpen(url): # Note that these strings DO NOT represent http responses. They are just # memorable numeric bug ids to use. if '200' in url: - return mockResponse(CLOSED_ISSUE_DATA) + return MockResponse(CLOSED_ISSUE_DATA) elif '201' in url: - return mockResponse(OPEN_ISSUE_DATA) + return MockResponse(OPEN_ISSUE_DATA) elif '300' in url: - return mockResponse(UNEXPECTED_FORMAT_DATA) + return MockResponse(UNEXPECTED_FORMAT_DATA) elif '403' in url: raise urllib2.URLError('') elif '404' in url: - return mockResponse('') + return MockResponse('') elif '500' in url: - return mockResponse(BROKEN_ISSUE_DATA) + return MockResponse(BROKEN_ISSUE_DATA) class crbugQueryTest(unittest.TestCase): - @mock.patch('urllib2.urlopen',mockUrlOpen) + @mock.patch('urllib2.urlopen', MockUrlOpen) def testClosedIssueIsClosed(self): self.assertTrue(CheckIssueClosed(200)) - @mock.patch('urllib2.urlopen',mockUrlOpen) + @mock.patch('urllib2.urlopen', MockUrlOpen) def testOpenIssueIsNotClosed(self): self.assertFalse(CheckIssueClosed(201)) - @mock.patch('urllib2.urlopen',mockUrlOpen) + @mock.patch('urllib2.urlopen', MockUrlOpen) def testUnexpectedFormat(self): self.assertFalse(CheckIssueClosed(300)) - @mock.patch('urllib2.urlopen',mockUrlOpen) + @mock.patch('urllib2.urlopen', MockUrlOpen) def testUrlError(self): self.assertFalse(CheckIssueClosed(403)) - @mock.patch('urllib2.urlopen',mockUrlOpen) + @mock.patch('urllib2.urlopen', MockUrlOpen) def testEmptyResponse(self): self.assertFalse(CheckIssueClosed(404)) - @mock.patch('urllib2.urlopen',mockUrlOpen) + @mock.patch('urllib2.urlopen', MockUrlOpen) def testBrokenResponse(self): self.assertFalse(CheckIssueClosed(500)) diff --git a/tools/auto_bisect/request_build.py b/tools/auto_bisect/request_build.py index c43cf5c..0035a95 100644 --- a/tools/auto_bisect/request_build.py +++ b/tools/auto_bisect/request_build.py @@ -11,16 +11,9 @@ This module can be either run as a stand-alone script to send a request to a builder, or imported and used by calling the public functions below. """ -import getpass import json -import optparse -import os -import sys -import urllib import urllib2 -import fetch_build - # URL template for fetching JSON data about builds. BUILDER_JSON_URL = ('%(server_url)s/json/builders/%(bot_name)s/builds/' '%(build_num)s?as_text=1&filter=0') @@ -109,13 +102,13 @@ def _IsBuildSuccessful(build_data): def _FetchBuilderData(builder_url): - """Fetches JSON data for the all the builds from the tryserver. + """Fetches JSON data for the all the builds from the try server. Args: - builder_url: A tryserver URL to fetch builds information. + builder_url: A try server URL to fetch builds information. Returns: - A dictionary with information of all build on the tryserver. + A dictionary with information of all build on the try server. """ data = None try: @@ -133,10 +126,10 @@ def _FetchBuilderData(builder_url): def _GetBuildData(buildbot_url): - """Gets build information for the given build id from the tryserver. + """Gets build information for the given build id from the try server. Args: - buildbot_url: A tryserver URL to fetch build information. + buildbot_url: A try server URL to fetch build information. Returns: A dictionary with build information if build exists, otherwise None. @@ -151,7 +144,7 @@ def GetBuildStatus(build_num, bot_name, server_url): """Gets build status from the buildbot status page for a given build number. Args: - build_num: A build number on tryserver to determine its status. + build_num: A build number on try server to determine its status. bot_name: Name of the bot where the build information is scanned. server_url: URL of the buildbot. @@ -188,13 +181,13 @@ def GetBuildNumFromBuilder(build_reason, bot_name, server_url): This function parses the JSON data from buildbot page and collects basic information about the all the builds, and then uniquely identifies the build - based on the 'reason' attribute in builds's JSON data. + based on the 'reason' attribute in the JSON data about the build. The 'reason' attribute set is when a build request is posted, and it is used to identify the build on status page. Args: - build_reason: A unique build name set to build on tryserver. + build_reason: A unique build name set to build on try server. bot_name: Name of the bot where the build information is scanned. server_url: URL of the buildbot. diff --git a/tools/auto_bisect/source_control.py b/tools/auto_bisect/source_control.py index 81d07a9..f528f24 100644 --- a/tools/auto_bisect/source_control.py +++ b/tools/auto_bisect/source_control.py @@ -137,10 +137,10 @@ def GetCommitPosition(git_revision, cwd=None): Returns: Git commit position as integer or None. """ - # Some of the respositories are pure git based, unlike other repositories + # Some of the repositories are pure git based, unlike other repositories # they doesn't have commit position. e.g., skia, angle. cmd = ['footers', '--position-num', git_revision] - output, return_code = bisect_utils.RunGit(cmd, cwd) + output, return_code = bisect_utils.RunGit(cmd, cwd) if not return_code: commit_position = output.strip() if bisect_utils.IsStringInt(commit_position): @@ -230,4 +230,3 @@ def QueryFileRevisionHistory(filename, revision_start, revision_end): output = bisect_utils.CheckRunGit(cmd) lines = output.split('\n') return [o for o in lines if o] - diff --git a/tools/auto_bisect/source_control_test.py b/tools/auto_bisect/source_control_test.py index ceba3e0..e8f05d3 100644 --- a/tools/auto_bisect/source_control_test.py +++ b/tools/auto_bisect/source_control_test.py @@ -81,4 +81,3 @@ def _SetMockCheckRunGitBehavior(mock_obj, command_output_map): if __name__ == '__main__': unittest.main() - |