OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 import collections | 5 import collections |
6 import contextlib | 6 import contextlib |
7 import copy | 7 import copy |
8 import itertools | 8 import itertools |
9 import json | 9 import json |
10 | 10 |
(...skipping 30 matching lines...) Expand all Loading... |
41 'chromium.fyi': 35, # This should be lower than the CQ. | 41 'chromium.fyi': 35, # This should be lower than the CQ. |
42 'chromium.memory.fyi': 27, | 42 'chromium.memory.fyi': 27, |
43 }) | 43 }) |
44 | 44 |
45 | 45 |
46 class ChromiumTestsApi(recipe_api.RecipeApi): | 46 class ChromiumTestsApi(recipe_api.RecipeApi): |
47 def __init__(self, *args, **kwargs): | 47 def __init__(self, *args, **kwargs): |
48 super(ChromiumTestsApi, self).__init__(*args, **kwargs) | 48 super(ChromiumTestsApi, self).__init__(*args, **kwargs) |
49 self._builders = {} | 49 self._builders = {} |
50 self.add_builders(builders.BUILDERS) | 50 self.add_builders(builders.BUILDERS) |
| 51 self._precommit_mode = False |
51 | 52 |
52 @property | 53 @property |
53 def builders(self): | 54 def builders(self): |
54 return self._builders | 55 return self._builders |
55 | 56 |
56 @property | 57 @property |
57 def steps(self): | 58 def steps(self): |
58 return steps | 59 return steps |
59 | 60 |
60 @property | 61 @property |
61 def trybots(self): | 62 def trybots(self): |
62 return trybots.TRYBOTS | 63 return trybots.TRYBOTS |
63 | 64 |
64 def add_builders(self, builders): | 65 def add_builders(self, builders): |
65 """Adds builders to our builder map""" | 66 """Adds builders to our builder map""" |
66 self._builders.update(builders) | 67 self._builders.update(builders) |
67 | 68 |
68 def create_bot_config_object(self, mastername, buildername): | 69 def create_bot_config_object(self, mastername, buildername): |
69 bot_id = {'mastername': mastername, 'buildername': buildername} | 70 bot_id = {'mastername': mastername, 'buildername': buildername} |
70 return bdb_module.BotConfig(self.builders, [bot_id]) | 71 return bdb_module.BotConfig(self.builders, [bot_id]) |
71 | 72 |
72 def create_generalized_bot_config_object(self, bot_ids): | 73 def create_generalized_bot_config_object(self, bot_ids): |
73 return bdb_module.BotConfig(self.builders, bot_ids) | 74 return bdb_module.BotConfig(self.builders, bot_ids) |
74 | 75 |
| 76 def set_precommit_mode(self): |
| 77 """Configures this module to indicate that tests are running before |
| 78 the changes are committed. This must be called very early in the |
| 79 recipe, certainly before prepare_checkout, and the action can not |
| 80 be undone. |
| 81 """ |
| 82 self._precommit_mode = True |
| 83 |
| 84 def is_precommit_mode(self): |
| 85 """Returns a Boolean indicating whether this module is running in |
| 86 precommit mode; i.e., whether tests are running before the changes |
| 87 are committed. |
| 88 """ |
| 89 return self._precommit_mode |
| 90 |
75 def configure_build(self, bot_config, override_bot_type=None): | 91 def configure_build(self, bot_config, override_bot_type=None): |
76 # Get the buildspec version. It can be supplied as a build property or as | 92 # Get the buildspec version. It can be supplied as a build property or as |
77 # a recipe config value. | 93 # a recipe config value. |
78 buildspec_version = (self.m.properties.get('buildspec_version') or | 94 buildspec_version = (self.m.properties.get('buildspec_version') or |
79 bot_config.get('buildspec_version')) | 95 bot_config.get('buildspec_version')) |
80 | 96 |
81 self.m.chromium.set_config( | 97 self.m.chromium.set_config( |
82 bot_config.get('chromium_config'), | 98 bot_config.get('chromium_config'), |
83 **bot_config.get('chromium_config_kwargs', {})) | 99 **bot_config.get('chromium_config_kwargs', {})) |
84 | 100 |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 lambda bot_id: bot_id['mastername'] == 'tryserver.chromium.perf' and | 202 lambda bot_id: bot_id['mastername'] == 'tryserver.chromium.perf' and |
187 bot_id['buildername'].endswith('builder')) | 203 bot_id['buildername'].endswith('builder')) |
188 and bot_config.get('bot_type') == 'builder'): | 204 and bot_config.get('bot_type') == 'builder'): |
189 if bot_config.should_force_legacy_compiling(self): | 205 if bot_config.should_force_legacy_compiling(self): |
190 self.m.chromium.c.project_generator.tool = 'gyp' | 206 self.m.chromium.c.project_generator.tool = 'gyp' |
191 | 207 |
192 self.set_up_swarming(bot_config) | 208 self.set_up_swarming(bot_config) |
193 self.runhooks(update_step) | 209 self.runhooks(update_step) |
194 | 210 |
195 bot_db = bdb_module.BotConfigAndTestDB() | 211 bot_db = bdb_module.BotConfigAndTestDB() |
196 bot_config.initialize_bot_db(self, bot_db) | 212 bot_config.initialize_bot_db(self, bot_db, update_step) |
197 | 213 |
198 if self.m.chromium.c.lto and \ | 214 if self.m.chromium.c.lto and \ |
199 not self.m.chromium.c.env.LLVM_FORCE_HEAD_REVISION: | 215 not self.m.chromium.c.env.LLVM_FORCE_HEAD_REVISION: |
200 self.m.chromium.download_lto_plugin() | 216 self.m.chromium.download_lto_plugin() |
201 | 217 |
202 return update_step, bot_db | 218 return update_step, bot_db |
203 | 219 |
204 def generate_tests_from_test_spec(self, api, test_spec, builder_dict, | 220 def generate_tests_from_test_spec(self, api, test_spec, builder_dict, |
205 buildername, mastername, enable_swarming, scripts_compile_targets, | 221 buildername, mastername, enable_swarming, scripts_compile_targets, |
206 generators): | 222 generators, bot_update_step): |
207 tests = builder_dict.get('tests', ()) | 223 tests = builder_dict.get('tests', ()) |
208 # TODO(phajdan.jr): Switch everything to scripts generators and simplify. | 224 # TODO(phajdan.jr): Switch everything to scripts generators and simplify. |
209 for generator in generators: | 225 for generator in generators: |
210 tests = ( | 226 tests = ( |
211 tuple(generator(api, mastername, buildername, test_spec, | 227 tuple(generator(api, self, mastername, buildername, test_spec, |
212 enable_swarming=enable_swarming, | 228 bot_update_step, enable_swarming=enable_swarming, |
213 scripts_compile_targets=scripts_compile_targets)) + | 229 scripts_compile_targets=scripts_compile_targets)) + |
214 tests) | 230 tests) |
215 return tests | 231 return tests |
216 | 232 |
217 def read_test_spec(self, api, test_spec_file): | 233 def read_test_spec(self, api, test_spec_file): |
218 test_spec_path = api.path['checkout'].join('testing', 'buildbot', | 234 test_spec_path = api.path['checkout'].join('testing', 'buildbot', |
219 test_spec_file) | 235 test_spec_file) |
220 test_spec_result = api.json.read( | 236 test_spec_result = api.json.read( |
221 'read test spec', | 237 'read test spec', |
222 test_spec_path, | 238 test_spec_path, |
(...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
804 def get_compile_targets_for_scripts(self): | 820 def get_compile_targets_for_scripts(self): |
805 return self.m.python( | 821 return self.m.python( |
806 name='get compile targets for scripts', | 822 name='get compile targets for scripts', |
807 script=self.m.path['checkout'].join( | 823 script=self.m.path['checkout'].join( |
808 'testing', 'scripts', 'get_compile_targets.py'), | 824 'testing', 'scripts', 'get_compile_targets.py'), |
809 args=[ | 825 args=[ |
810 '--output', self.m.json.output(), | 826 '--output', self.m.json.output(), |
811 '--', | 827 '--', |
812 ] + self.get_common_args_for_scripts(), | 828 ] + self.get_common_args_for_scripts(), |
813 step_test_data=lambda: self.m.json.test_api.output({})) | 829 step_test_data=lambda: self.m.json.test_api.output({})) |
OLD | NEW |