OLD | NEW |
---|---|
(Empty) | |
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 | |
3 # found in the LICENSE file. | |
4 | |
5 """Top-level presubmit script for testing. | |
tonyg
2013/02/14 23:30:06
Comment needs updating
shatch
2013/02/14 23:59:46
Done.
| |
6 | |
7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts for | |
8 details on the presubmit API built into gcl. | |
9 """ | |
10 | |
11 import imp | |
12 | |
13 def _ExamineBisectConfigFile(input_api, output_api): | |
14 for f in input_api.AffectedFiles(): | |
15 if not f.LocalPath().endswith('run-bisect-perf-regression.cfg'): | |
16 continue | |
17 | |
18 try: | |
19 cfg_file = imp.load_source('config', 'run-bisect-perf-regression.cfg') | |
20 | |
21 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
| |
22 | |
23 for k, v in cfg_file.config.iteritems(): | |
24 if not k in valid_keys or v: | |
25 return f.LocalPath() | |
26 except (IOError, AttributeError, TypeError): | |
27 return f.LocalPath() | |
28 | |
29 return None | |
30 | |
31 def _CheckNoChangesToBisectConfigFile(input_api, output_api): | |
32 results = _ExamineBisectConfigFile(input_api, output_api) | |
33 if results: | |
34 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
| |
35 'The bisection config file should only contain a config dict with ' | |
36 'empty fields. Changes to this file should never be submitted.', | |
37 items=[results])] | |
38 | |
39 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) | |
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
| |
48 | |
49 def CheckChangeOnCommit(input_api, output_api): | |
50 return CommonChecks(input_api, output_api) | |
OLD | NEW |