OLD | NEW |
| (Empty) |
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 | |
3 # found in the LICENSE file. | |
4 | |
5 from recipe_engine.types import freeze | |
6 | |
7 DEPS = [ | |
8 'depot_tools/bot_update', | |
9 'chromium', | |
10 'chromium_tests', | |
11 'recipe_engine/json', | |
12 'recipe_engine/path', | |
13 'recipe_engine/platform', | |
14 'recipe_engine/properties', | |
15 'recipe_engine/python', | |
16 'recipe_engine/step', | |
17 'test_utils', | |
18 'depot_tools/tryserver', | |
19 'webrtc', | |
20 ] | |
21 | |
22 | |
23 BUILDERS = freeze({ | |
24 'tryserver.v8': { | |
25 'builders': { | |
26 'v8_linux_chromium_gn_rel': { | |
27 'chromium_config_kwargs': { | |
28 'BUILD_CONFIG': 'Release', | |
29 'TARGET_PLATFORM': 'linux', | |
30 'TARGET_BITS': 64, | |
31 }, | |
32 'gclient_apply_config': [ | |
33 'v8_bleeding_edge_git', | |
34 'chromium_lkcr', | |
35 'show_v8_revision', | |
36 ], | |
37 'root_override': 'src/v8', | |
38 'set_component_rev': {'name': 'src/v8', 'rev_str': '%s'}, | |
39 }, | |
40 'v8_android_chromium_gn_dbg': { | |
41 'chromium_apply_config': ['gn_minimal_symbols'], | |
42 'chromium_config_kwargs': { | |
43 'BUILD_CONFIG': 'Debug', | |
44 'TARGET_PLATFORM': 'android', | |
45 'TARGET_ARCH': 'arm', | |
46 }, | |
47 'gclient_apply_config': [ | |
48 'android', | |
49 'v8_bleeding_edge_git', | |
50 'chromium_lkcr', | |
51 'show_v8_revision', | |
52 ], | |
53 'root_override': 'src/v8', | |
54 'set_component_rev': {'name': 'src/v8', 'rev_str': '%s'}, | |
55 }, | |
56 }, | |
57 }, | |
58 'client.v8.fyi': { | |
59 'builders': { | |
60 'V8 Linux GN': { | |
61 'chromium_config_kwargs': { | |
62 'BUILD_CONFIG': 'Release', | |
63 'TARGET_PLATFORM': 'linux', | |
64 'TARGET_BITS': 64, | |
65 }, | |
66 'gclient_apply_config': [ | |
67 'v8_bleeding_edge_git', | |
68 'chromium_lkcr', | |
69 'show_v8_revision', | |
70 ], | |
71 'set_component_rev': {'name': 'src/v8', 'rev_str': '%s'}, | |
72 }, | |
73 'V8 Android GN (dbg)': { | |
74 'chromium_apply_config': ['gn_minimal_symbols'], | |
75 'chromium_config_kwargs': { | |
76 'BUILD_CONFIG': 'Debug', | |
77 'TARGET_PLATFORM': 'android', | |
78 'TARGET_ARCH': 'arm', | |
79 }, | |
80 'gclient_apply_config': [ | |
81 'android', | |
82 'v8_bleeding_edge_git', | |
83 'chromium_lkcr', | |
84 'show_v8_revision', | |
85 ], | |
86 'set_component_rev': {'name': 'src/v8', 'rev_str': '%s'}, | |
87 }, | |
88 }, | |
89 }, | |
90 }) | |
91 | |
92 def tests_in_compile_targets(api, compile_targets, tests): | |
93 """Returns the tests in |tests| that have at least one of their compile | |
94 targets in |compile_targets|.""" | |
95 result = [] | |
96 for test in tests: | |
97 test_compile_targets = test.compile_targets(api) | |
98 | |
99 # Always return tests that don't require compile. Otherwise we'd never | |
100 # run them. | |
101 if ((set(compile_targets).intersection(set(test_compile_targets))) or | |
102 not test_compile_targets): | |
103 result.append(test) | |
104 | |
105 return result | |
106 | |
107 | |
108 def all_compile_targets(api, tests): | |
109 """Returns the compile_targets for all the Tests in |tests|.""" | |
110 return sorted(set(x | |
111 for test in tests | |
112 for x in test.compile_targets(api))) | |
113 | |
114 | |
115 def _RunStepsInternal(api): | |
116 mastername = api.properties.get('mastername') | |
117 buildername = api.properties.get('buildername') | |
118 bot_config = BUILDERS[mastername]['builders'][buildername] | |
119 is_android = ('Android' in buildername or 'android' in buildername) | |
120 force_clobber = bot_config.get('force_clobber', False) | |
121 | |
122 api.chromium.configure_bot(BUILDERS, ['mb']) | |
123 bot_update_step = api.bot_update.ensure_checkout( | |
124 force=True, patch_root=bot_config.get('root_override')) | |
125 | |
126 # because the 'mb' config is applied, we skip running gyp in the | |
127 # the runhooks step. | |
128 api.chromium.runhooks() | |
129 | |
130 # TODO(dpranke): Unify this with the logic in the chromium_trybot and | |
131 # chromium recipes so that we can actually run the tests as well | |
132 # and deapply patches and retry as need be. | |
133 test_spec_file = '%s.json' % mastername | |
134 test_spec = api.chromium_tests.read_test_spec(api, test_spec_file) | |
135 | |
136 tests = list(api.chromium_tests.steps.generate_gtest( | |
137 api, api.chromium_tests, mastername, buildername, test_spec, | |
138 bot_update_step)) | |
139 | |
140 scripts_compile_targets = \ | |
141 api.chromium_tests.get_compile_targets_for_scripts().json.output | |
142 tests += list(api.chromium_tests.steps.generate_script( | |
143 api, api.chromium_tests, mastername, buildername, test_spec, | |
144 bot_update_step, scripts_compile_targets=scripts_compile_targets)) | |
145 | |
146 additional_compile_targets = test_spec.get(buildername, {}).get( | |
147 'additional_compile_targets', | |
148 ['chrome_public_apk' if is_android else 'all']) | |
149 | |
150 if api.tryserver.is_tryserver: | |
151 affected_files = api.tryserver.get_files_affected_by_patch() | |
152 | |
153 test_targets = all_compile_targets(api, tests) | |
154 | |
155 test_targets, compile_targets = \ | |
156 api.chromium_tests.analyze( | |
157 affected_files, | |
158 test_targets, | |
159 additional_compile_targets, | |
160 'trybot_analyze_config.json') | |
161 if compile_targets: | |
162 api.chromium.run_mb(mastername, buildername, use_goma=True) | |
163 api.chromium.compile(compile_targets, | |
164 force_clobber=force_clobber) | |
165 tests = tests_in_compile_targets(api, test_targets, tests) | |
166 else: | |
167 api.chromium.run_mb(mastername, buildername, use_goma=True) | |
168 api.chromium.compile(all_compile_targets(api, tests) + | |
169 additional_compile_targets, | |
170 force_clobber=force_clobber) | |
171 | |
172 if tests: | |
173 bot_config_object = api.chromium_tests.create_bot_config_object( | |
174 mastername, buildername) | |
175 if api.tryserver.is_tryserver: | |
176 api.chromium_tests.run_tests_on_tryserver( | |
177 bot_config_object, api, tests, bot_update_step, affected_files) | |
178 else: | |
179 api.chromium_tests.configure_swarming('chromium', precommit=False, | |
180 mastername=mastername) | |
181 test_runner = api.chromium_tests.create_test_runner(api, tests) | |
182 with api.chromium_tests.wrap_chromium_tests(bot_config_object, tests): | |
183 test_runner() | |
184 | |
185 | |
186 def RunSteps(api): | |
187 with api.tryserver.set_failure_hash(): | |
188 return _RunStepsInternal(api) | |
189 | |
190 | |
191 def GenTests(api): | |
192 overrides = {} | |
193 for mastername, master_dict in BUILDERS.items(): | |
194 for buildername in master_dict['builders']: | |
195 | |
196 # The Android bots are currently all only builders and cannot | |
197 # run tests; more importantly, the recipe isn't set up to run | |
198 # tests on Android correctly, and if we specify any tests in | |
199 # the step_data, the recipe will crash :). We will eventually | |
200 # fix this by killing this recipe altogether and moving to the | |
201 # main chromium recipes. | |
202 is_android = ('Android' in buildername or 'android' in buildername) | |
203 gtest_tests = [] if is_android else ['base_unittests'] | |
204 | |
205 overrides.setdefault(mastername, {}) | |
206 overrides[mastername][buildername] = ( | |
207 api.override_step_data( | |
208 'read test spec', | |
209 api.json.output({ | |
210 buildername: { | |
211 'gtest_tests': gtest_tests, | |
212 }, | |
213 }))) | |
214 | |
215 if 'tryserver' in mastername: | |
216 overrides[mastername][buildername] += api.override_step_data( | |
217 'analyze', | |
218 api.json.output({ | |
219 'status': 'Found dependency', | |
220 'test_targets': gtest_tests, | |
221 'compile_targets': gtest_tests, | |
222 })) | |
223 | |
224 for test in api.chromium.gen_tests_for_builders(BUILDERS, overrides): | |
225 yield test | |
226 | |
227 yield ( | |
228 api.test('compile_failure') + | |
229 api.platform.name('linux') + | |
230 api.properties.tryserver( | |
231 buildername='v8_linux_chromium_gn_rel', | |
232 mastername='tryserver.v8') + | |
233 api.step_data('compile', retcode=1) + | |
234 overrides['tryserver.v8']['v8_linux_chromium_gn_rel'] | |
235 ) | |
236 | |
237 yield ( | |
238 api.test('use_v8_patch_on_chromium_gn_trybot') + | |
239 api.platform.name('linux') + | |
240 api.properties.tryserver( | |
241 buildername='v8_linux_chromium_gn_rel', | |
242 mastername='tryserver.v8', | |
243 patch_project='v8') + | |
244 overrides['tryserver.v8']['v8_linux_chromium_gn_rel'] | |
245 ) | |
246 | |
247 yield ( | |
248 api.test('no_tests_run') + | |
249 api.platform.name('linux') + | |
250 api.properties.tryserver( | |
251 buildername='v8_linux_chromium_gn_rel', | |
252 mastername='tryserver.v8') + | |
253 api.override_step_data( | |
254 'read test spec', | |
255 api.json.output({'linux_chromium_gn_rel': { | |
256 'additional_compile_targets': ['net_unittests'], | |
257 'gtest_tests': ['base_unittests'], | |
258 }})) + | |
259 api.override_step_data( | |
260 'analyze', | |
261 api.json.output({ | |
262 'status': 'Found dependency', | |
263 'test_targets': ['net_unittests'], | |
264 'compile_targets': ['net_unittests'], | |
265 })) | |
266 ) | |
OLD | NEW |