Chromium Code Reviews| Index: build/util/PRESUBMIT.py |
| diff --git a/build/util/PRESUBMIT.py b/build/util/PRESUBMIT.py |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..b5685ac625915d8484322866b4054a2dfa044c1c |
| --- /dev/null |
| +++ b/build/util/PRESUBMIT.py |
| @@ -0,0 +1,50 @@ |
| +# Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| +# 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 testing. |
|
tonyg
2013/02/14 23:30:06
Comment needs updating
shatch
2013/02/14 23:59:46
Done.
|
| + |
| +See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts for |
| +details on the presubmit API built into gcl. |
| +""" |
| + |
| +import imp |
| + |
| +def _ExamineBisectConfigFile(input_api, output_api): |
| + for f in input_api.AffectedFiles(): |
| + if not f.LocalPath().endswith('run-bisect-perf-regression.cfg'): |
| + continue |
| + |
| + try: |
| + cfg_file = imp.load_source('config', 'run-bisect-perf-regression.cfg') |
| + |
| + valid_keys = ['command', 'good_revision', 'bad_revision', 'metric'] |
|
tonyg
2013/02/14 23:30:06
I'm not sure I'd lock down the key names. We might
shatch
2013/02/14 23:59:46
If you added a new key name, would you not want PR
|
| + |
| + for k, v in cfg_file.config.iteritems(): |
| + if not k in valid_keys or v: |
| + return f.LocalPath() |
| + except (IOError, AttributeError, TypeError): |
| + return f.LocalPath() |
| + |
| + return None |
| + |
| +def _CheckNoChangesToBisectConfigFile(input_api, output_api): |
| + results = _ExamineBisectConfigFile(input_api, output_api) |
| + if results: |
| + return [output_api.PresubmitError( |
|
shatch
2013/02/14 23:00:34
Should this be just a warning or an error?
tonyg
2013/02/14 23:30:06
error sounds good
|
| + '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 CommonChecks(input_api, output_api): |
| + results = [] |
| + results.extend(_CheckNoChangesToBisectConfigFile(input_api, output_api)) |
| + return results |
| + |
| +def CheckChangeOnUpload(input_api, output_api): |
| + return CommonChecks(input_api, output_api) |
|
tonyg
2013/02/14 23:30:06
I'm not sure I'd perform this check on upload. Jus
shatch
2013/02/14 23:59:46
I'm a little unfamiliar with the PRESUBMIT scripts
|
| + |
| +def CheckChangeOnCommit(input_api, output_api): |
| + return CommonChecks(input_api, output_api) |