OLD | NEW |
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 trybot. | 5 """Top-level presubmit script for bisect/perf trybot. |
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 | 13 |
13 def _ExamineBisectConfigFile(input_api, output_api): | 14 def _ExamineConfigFiles(input_api): |
14 for f in input_api.AffectedFiles(): | 15 for f in input_api.AffectedFiles(): |
15 if not f.LocalPath().endswith('run-bisect-perf-regression.cfg'): | 16 if (not f.LocalPath().endswith('run-bisect-perf-regression.cfg') and |
| 17 not f.LocalPath().endswith('run-perf-test.cfg')): |
16 continue | 18 continue |
17 | 19 |
18 try: | 20 try: |
19 cfg_file = imp.load_source('config', 'run-bisect-perf-regression.cfg') | 21 cfg_file = imp.load_source('config', os.path.basename(f.LocalPath())) |
20 | 22 |
21 for k, v in cfg_file.config.iteritems(): | 23 for k, v in cfg_file.config.iteritems(): |
22 if v: | 24 if v: |
23 return f.LocalPath() | 25 return f.LocalPath() |
24 except (IOError, AttributeError, TypeError): | 26 except (IOError, AttributeError, TypeError): |
25 return f.LocalPath() | 27 return f.LocalPath() |
26 | 28 |
27 return None | 29 return None |
28 | 30 |
29 def _CheckNoChangesToBisectConfigFile(input_api, output_api): | 31 def _CheckNoChangesToBisectConfigFile(input_api, output_api): |
30 results = _ExamineBisectConfigFile(input_api, output_api) | 32 results = _ExamineConfigFiles(input_api) |
31 if results: | 33 if results: |
32 return [output_api.PresubmitError( | 34 return [output_api.PresubmitError( |
33 'The bisection config file should only contain a config dict with ' | 35 'The bisection config file should only contain a config dict with ' |
34 'empty fields. Changes to this file should never be submitted.', | 36 'empty fields. Changes to this file should never be submitted.', |
35 items=[results])] | 37 items=[results])] |
36 | 38 |
37 return [] | 39 return [] |
38 | 40 |
39 def CommonChecks(input_api, output_api): | 41 def CommonChecks(input_api, output_api): |
40 results = [] | 42 results = [] |
41 results.extend(_CheckNoChangesToBisectConfigFile(input_api, output_api)) | 43 results.extend(_CheckNoChangesToBisectConfigFile(input_api, output_api)) |
42 return results | 44 return results |
43 | 45 |
44 def CheckChangeOnUpload(input_api, output_api): | 46 def CheckChangeOnUpload(input_api, output_api): |
45 return CommonChecks(input_api, output_api) | 47 return CommonChecks(input_api, output_api) |
46 | 48 |
47 def CheckChangeOnCommit(input_api, output_api): | 49 def CheckChangeOnCommit(input_api, output_api): |
48 return CommonChecks(input_api, output_api) | 50 return CommonChecks(input_api, output_api) |
OLD | NEW |