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

Side by Side 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, 3 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 unified diff | Download patch
« no previous file with comments | « no previous file | tools/auto_bisect/README » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2013 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 """Top-level presubmit script for bisect/perf trybot. 5 """Top-level presubmit script for auto-bisect.
6 6
7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts for 7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts for
8 details on the presubmit API built into gcl. 8 details on the presubmit API built into gcl.
9 """ 9 """
10 10
11 import imp 11 import imp
12 import os 12 import os
13 13
14 def _ExamineConfigFiles(input_api): 14 # Paths to bisect config files relative to src/tools.
15 CONFIG_FILES = [
16 'auto_bisect/config.cfg',
17 'run-perf-test.cfg'
18 ]
19
20 PYLINT_BLACKLIST = []
21 PYLINT_DISABLED_WARNINGS = []
22
23
24 def CheckChangeOnUpload(input_api, output_api):
25 return _CommonChecks(input_api, output_api)
26
27
28 def CheckChangeOnCommit(input_api, output_api):
29 return _CommonChecks(input_api, output_api)
30
31
32 def _CommonChecks(input_api, output_api):
33 """Does all presubmit checks for auto-bisect."""
34 # TODO(qyearsley) Run bisect unit test.
35 # TODO(qyearsley) Run pylint on all auto-bisect py files but not other files.
36 results = []
37 results.extend(_CheckAllConfigFiles(input_api, output_api))
38 return results
39
40
41 def _CheckAllConfigFiles(input_api, output_api):
42 """Checks all bisect config files and returns a list of presubmit results."""
43 results = []
15 for f in input_api.AffectedFiles(): 44 for f in input_api.AffectedFiles():
16 if (not f.LocalPath().endswith('run-bisect-perf-regression.cfg') and 45 for config_file in CONFIG_FILES:
17 not f.LocalPath().endswith('run-perf-test.cfg')): 46 if f.LocalPath().endswith(config_file):
18 continue 47 results.extend(_CheckConfigFile(config_file, output_api))
48 return results
19 49
20 try:
21 cfg_file = imp.load_source('config', os.path.basename(f.LocalPath()))
22 50
23 for k, v in cfg_file.config.iteritems(): 51 def _CheckConfigFile(file_path, output_api):
24 if v: 52 """Checks one bisect config file and returns a list of presubmit results."""
25 return f.LocalPath() 53 try:
26 except (IOError, AttributeError, TypeError): 54 config_file = imp.load_source('config', file_path)
27 return f.LocalPath() 55 except IOError as e:
56 warning = 'Failed to read config file %s: %s' % (file_path, str(e))
57 return [output_api.PresubmitError(warning, items=[file_path])]
28 58
29 return None 59 if not hasattr(config_file.config):
60 warning = 'Config file has no "config" global variable: %s' % str(e)
61 return [output_api.PresubmitError(warning, items=[file_path])]
30 62
31 def _CheckNoChangesToBisectConfigFile(input_api, output_api): 63 if type(config_file.config) is not dict:
32 results = _ExamineConfigFiles(input_api) 64 warning = 'Config file "config" global variable is not dict: %s' % str(e)
33 if results: 65 return [output_api.PresubmitError(warning, items=[file_path])]
34 return [output_api.PresubmitError( 66
35 'The bisection config file should only contain a config dict with ' 67 for k, v in config_dict.iteritems():
36 'empty fields. Changes to this file should never be submitted.', 68 if v != '':
37 items=[results])] 69 warning = 'Non-empty value in config dict: %s: %s' % (repr(k), repr(v))
70 warning += ('\nThe bisection config file should only contain a config '
71 'dict with empty fields. Changes to this file should not '
72 'be submitted.')
73 return [output_api.PresubmitError(warning, items=[file_path])]
38 74
39 return [] 75 return []
40
41 def CommonChecks(input_api, output_api):
42 results = []
43 results.extend(_CheckNoChangesToBisectConfigFile(input_api, output_api))
44 return results
45
46 def CheckChangeOnUpload(input_api, output_api):
47 return CommonChecks(input_api, output_api)
48
49 def CheckChangeOnCommit(input_api, output_api):
50 return CommonChecks(input_api, output_api)
OLDNEW
« 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