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 return bdb_module.BotConfig( | 70 return bdb_module.BotConfig( |
70 self.builders, | 71 self.builders, |
71 [{'mastername': mastername, 'buildername': buildername}]) | 72 [{'mastername': mastername, 'buildername': buildername}]) |
72 | 73 |
| 74 def set_precommit_mode(self): |
| 75 """Configures this module to indicate that tests are running before |
| 76 the changes are committed. This must be called very early in the |
| 77 recipe, certainly before prepare_checkout, and the action can not |
| 78 be undone. |
| 79 """ |
| 80 self._precommit_mode = True |
| 81 |
| 82 def is_precommit_mode(self): |
| 83 """Returns a Boolean indicating whether this module is running in |
| 84 precommit mode; i.e., whether tests are running before the changes |
| 85 are committed. |
| 86 """ |
| 87 return self._precommit_mode |
| 88 |
73 def configure_build(self, bot_config, override_bot_type=None): | 89 def configure_build(self, bot_config, override_bot_type=None): |
74 # Get the buildspec version. It can be supplied as a build property or as | 90 # Get the buildspec version. It can be supplied as a build property or as |
75 # a recipe config value. | 91 # a recipe config value. |
76 buildspec_version = (self.m.properties.get('buildspec_version') or | 92 buildspec_version = (self.m.properties.get('buildspec_version') or |
77 bot_config.get('buildspec_version')) | 93 bot_config.get('buildspec_version')) |
78 | 94 |
79 self.m.chromium.set_config( | 95 self.m.chromium.set_config( |
80 bot_config.get('chromium_config'), | 96 bot_config.get('chromium_config'), |
81 **bot_config.get('chromium_config_kwargs', {})) | 97 **bot_config.get('chromium_config_kwargs', {})) |
82 | 98 |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 lambda bot_id: bot_id['mastername'] == 'tryserver.chromium.perf' and | 200 lambda bot_id: bot_id['mastername'] == 'tryserver.chromium.perf' and |
185 bot_id['buildername'].endswith('builder')) | 201 bot_id['buildername'].endswith('builder')) |
186 and bot_config.get('bot_type') == 'builder'): | 202 and bot_config.get('bot_type') == 'builder'): |
187 if bot_config.should_force_legacy_compiling(self): | 203 if bot_config.should_force_legacy_compiling(self): |
188 self.m.chromium.c.project_generator.tool = 'gyp' | 204 self.m.chromium.c.project_generator.tool = 'gyp' |
189 | 205 |
190 self.set_up_swarming(bot_config) | 206 self.set_up_swarming(bot_config) |
191 self.runhooks(update_step) | 207 self.runhooks(update_step) |
192 | 208 |
193 bot_db = bdb_module.BotConfigAndTestDB() | 209 bot_db = bdb_module.BotConfigAndTestDB() |
194 bot_config.initialize_bot_db(self, bot_db) | 210 bot_config.initialize_bot_db(self, bot_db, update_step) |
195 | 211 |
196 if self.m.chromium.c.lto and \ | 212 if self.m.chromium.c.lto and \ |
197 not self.m.chromium.c.env.LLVM_FORCE_HEAD_REVISION: | 213 not self.m.chromium.c.env.LLVM_FORCE_HEAD_REVISION: |
198 self.m.chromium.download_lto_plugin() | 214 self.m.chromium.download_lto_plugin() |
199 | 215 |
200 return update_step, bot_db | 216 return update_step, bot_db |
201 | 217 |
202 def generate_tests_from_test_spec(self, api, test_spec, builder_dict, | 218 def generate_tests_from_test_spec(self, api, test_spec, builder_dict, |
203 buildername, mastername, enable_swarming, scripts_compile_targets, | 219 buildername, mastername, enable_swarming, scripts_compile_targets, |
204 generators): | 220 generators, bot_update_step): |
205 tests = builder_dict.get('tests', ()) | 221 tests = builder_dict.get('tests', ()) |
206 # TODO(phajdan.jr): Switch everything to scripts generators and simplify. | 222 # TODO(phajdan.jr): Switch everything to scripts generators and simplify. |
207 for generator in generators: | 223 for generator in generators: |
208 tests = ( | 224 tests = ( |
209 tuple(generator(api, mastername, buildername, test_spec, | 225 tuple(generator(api, self, mastername, buildername, test_spec, |
210 enable_swarming=enable_swarming, | 226 bot_update_step, enable_swarming=enable_swarming, |
211 scripts_compile_targets=scripts_compile_targets)) + | 227 scripts_compile_targets=scripts_compile_targets)) + |
212 tests) | 228 tests) |
213 return tests | 229 return tests |
214 | 230 |
215 def read_test_spec(self, api, test_spec_file): | 231 def read_test_spec(self, api, test_spec_file): |
216 test_spec_path = api.path['checkout'].join('testing', 'buildbot', | 232 test_spec_path = api.path['checkout'].join('testing', 'buildbot', |
217 test_spec_file) | 233 test_spec_file) |
218 test_spec_result = api.json.read( | 234 test_spec_result = api.json.read( |
219 'read test spec', | 235 'read test spec', |
220 test_spec_path, | 236 test_spec_path, |
(...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
783 def get_compile_targets_for_scripts(self): | 799 def get_compile_targets_for_scripts(self): |
784 return self.m.python( | 800 return self.m.python( |
785 name='get compile targets for scripts', | 801 name='get compile targets for scripts', |
786 script=self.m.path['checkout'].join( | 802 script=self.m.path['checkout'].join( |
787 'testing', 'scripts', 'get_compile_targets.py'), | 803 'testing', 'scripts', 'get_compile_targets.py'), |
788 args=[ | 804 args=[ |
789 '--output', self.m.json.output(), | 805 '--output', self.m.json.output(), |
790 '--', | 806 '--', |
791 ] + self.get_common_args_for_scripts(), | 807 ] + self.get_common_args_for_scripts(), |
792 step_test_data=lambda: self.m.json.test_api.output({})) | 808 step_test_data=lambda: self.m.json.test_api.output({})) |
OLD | NEW |