Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(314)

Unified Diff: tools/PRESUBMIT.py

Issue 511043002: Rename run-bisect-perf-regression.cfg -> auto_bisect/bisect.cfg (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix PRESUBMIT.py so that it checks for the config file in its new location. Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tools/auto_bisect/README » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/PRESUBMIT.py
diff --git a/tools/PRESUBMIT.py b/tools/PRESUBMIT.py
index aff6048f1a8a45e277e3e771a281f0e167d65360..e7b9b25faa8de33fe4437a365d011eabf094f741 100644
--- a/tools/PRESUBMIT.py
+++ b/tools/PRESUBMIT.py
@@ -2,7 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-"""Top-level presubmit script for bisect/perf trybot.
+"""Top-level presubmit script for auto-bisect.
See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts for
details on the presubmit API built into gcl.
@@ -11,40 +11,65 @@ details on the presubmit API built into gcl.
import imp
import os
-def _ExamineConfigFiles(input_api):
- for f in input_api.AffectedFiles():
- if (not f.LocalPath().endswith('run-bisect-perf-regression.cfg') and
- not f.LocalPath().endswith('run-perf-test.cfg')):
- continue
+# Paths to bisect config files relative to src/tools.
+CONFIG_FILES = [
+ 'auto_bisect/config.cfg',
+ 'run-perf-test.cfg'
+]
- try:
- cfg_file = imp.load_source('config', os.path.basename(f.LocalPath()))
+PYLINT_BLACKLIST = []
+PYLINT_DISABLED_WARNINGS = []
- for k, v in cfg_file.config.iteritems():
- if v:
- return f.LocalPath()
- except (IOError, AttributeError, TypeError):
- return f.LocalPath()
- return None
+def CheckChangeOnUpload(input_api, output_api):
+ return _CommonChecks(input_api, output_api)
-def _CheckNoChangesToBisectConfigFile(input_api, output_api):
- results = _ExamineConfigFiles(input_api)
- if results:
- return [output_api.PresubmitError(
- 'The bisection config file should only contain a config dict with '
- 'empty fields. Changes to this file should never be submitted.',
- items=[results])]
- return []
+def CheckChangeOnCommit(input_api, output_api):
+ return _CommonChecks(input_api, output_api)
+
-def CommonChecks(input_api, output_api):
+def _CommonChecks(input_api, output_api):
+ """Does all presubmit checks for auto-bisect."""
+ # TODO(qyearsley) Run bisect unit test.
+ # TODO(qyearsley) Run pylint on all auto-bisect py files but not other files.
results = []
- results.extend(_CheckNoChangesToBisectConfigFile(input_api, output_api))
+ results.extend(_CheckAllConfigFiles(input_api, output_api))
return results
-def CheckChangeOnUpload(input_api, output_api):
- return CommonChecks(input_api, output_api)
-def CheckChangeOnCommit(input_api, output_api):
- return CommonChecks(input_api, output_api)
+def _CheckAllConfigFiles(input_api, output_api):
+ """Checks all bisect config files and returns a list of presubmit results."""
+ results = []
+ for f in input_api.AffectedFiles():
+ for config_file in CONFIG_FILES:
+ if f.LocalPath().endswith(config_file):
+ results.extend(_CheckConfigFile(config_file, output_api))
+ return results
+
+
+def _CheckConfigFile(file_path, output_api):
+ """Checks one bisect config file and returns a list of presubmit results."""
+ try:
+ config_file = imp.load_source('config', file_path)
+ except IOError as e:
+ warning = 'Failed to read config file %s: %s' % (file_path, str(e))
+ return [output_api.PresubmitError(warning, items=[file_path])]
+
+ if not hasattr(config_file.config):
+ warning = 'Config file has no "config" global variable: %s' % str(e)
+ return [output_api.PresubmitError(warning, items=[file_path])]
+
+ if type(config_file.config) is not dict:
+ warning = 'Config file "config" global variable is not dict: %s' % str(e)
+ return [output_api.PresubmitError(warning, items=[file_path])]
+
+ for k, v in config_dict.iteritems():
+ if v != '':
+ warning = 'Non-empty value in config dict: %s: %s' % (repr(k), repr(v))
+ warning += ('\nThe bisection config file should only contain a config '
+ 'dict with empty fields. Changes to this file should not '
+ 'be submitted.')
+ return [output_api.PresubmitError(warning, items=[file_path])]
+
+ return []
« no previous file with comments | « no previous file | tools/auto_bisect/README » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698