Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(889)

Side by Side Diff: recipe_engine/autoroll.py

Issue 2790493007: test: promote --train to its own subcommand (Closed)
Patch Set: deprectaed Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | recipe_engine/test.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2016 The LUCI Authors. All rights reserved. 1 # Copyright 2016 The LUCI Authors. All rights reserved.
2 # Use of this source code is governed under the Apache License, Version 2.0 2 # Use of this source code is governed under the Apache License, Version 2.0
3 # that can be found in the LICENSE file. 3 # that can be found in the LICENSE file.
4 4
5 from __future__ import print_function 5 from __future__ import print_function
6 6
7 import json 7 import json
8 import os 8 import os
9 import subprocess 9 import subprocess
10 import sys 10 import sys
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 """ 124 """
125 # Use _local_ recipes.py, so that it checks out the pinned recipe engine, 125 # Use _local_ recipes.py, so that it checks out the pinned recipe engine,
126 # rather than running recipe engine which may be at a different revision 126 # rather than running recipe engine which may be at a different revision
127 # than the pinned one. 127 # than the pinned one.
128 args = [ 128 args = [
129 sys.executable, 129 sys.executable,
130 os.path.join(repo_root, package_spec.recipes_path, 'recipes.py'), 130 os.path.join(repo_root, package_spec.recipes_path, 'recipes.py'),
131 ] 131 ]
132 if not allow_fetch: 132 if not allow_fetch:
133 args.append('--no-fetch') 133 args.append('--no-fetch')
134 args.extend(['test', 'run']) 134 args.append('test')
135 if additional_args: 135 if additional_args:
136 args.extend(additional_args) 136 args.extend(additional_args)
137 p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) 137 p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
138 output, _ = p.communicate() 138 output, _ = p.communicate()
139 rc = p.returncode 139 rc = p.returncode
140 return rc, output 140 return rc, output
141 141
142 142
143 def process_candidates(candidates, context, config_file, package_spec): 143 def process_candidates(candidates, context, config_file, package_spec):
144 roll_details = [] 144 roll_details = []
(...skipping 17 matching lines...) Expand all
162 # the maximal one, e.g. to jump over some reverts, or include fixes 162 # the maximal one, e.g. to jump over some reverts, or include fixes
163 # landed later for incompatible API changes. 163 # landed later for incompatible API changes.
164 for i, candidate in enumerate(candidates): 164 for i, candidate in enumerate(candidates):
165 print(' processing candidate #%d... ' % (i + 1), end='') 165 print(' processing candidate #%d... ' % (i + 1), end='')
166 166
167 spec = candidate.get_rolled_spec() 167 spec = candidate.get_rolled_spec()
168 config_file.write(spec.dump()) 168 config_file.write(spec.dump())
169 fetch(context.repo_root, package_spec) 169 fetch(context.repo_root, package_spec)
170 write_new_recipes_py(context, spec, repo_cfg_block) 170 write_new_recipes_py(context, spec, repo_cfg_block)
171 171
172 rc, output = run_simulation_test(context.repo_root, package_spec) 172 rc, output = run_simulation_test(context.repo_root, package_spec, ['run'])
173 roll_details[i]['recipes_simulation_test'] = { 173 roll_details[i]['recipes_simulation_test'] = {
174 'output': output, 174 'output': output,
175 'rc': rc, 175 'rc': rc,
176 } 176 }
177 177
178 if rc == 0: 178 if rc == 0:
179 print('SUCCESS!') 179 print('SUCCESS!')
180 trivial = True 180 trivial = True
181 picked_roll_details = roll_details[i] 181 picked_roll_details = roll_details[i]
182 break 182 break
183 else: 183 else:
184 print('FAILED') 184 print('FAILED')
185 185
186 if not picked_roll_details: 186 if not picked_roll_details:
187 print('looking for a nontrivial roll...') 187 print('looking for a nontrivial roll...')
188 188
189 # Process candidates smallest first. If the roll is going to change 189 # Process candidates smallest first. If the roll is going to change
190 # expectations, it should be minimal to avoid pulling too many unrelated 190 # expectations, it should be minimal to avoid pulling too many unrelated
191 # changes. 191 # changes.
192 for i, candidate in reversed(list(enumerate(candidates))): 192 for i, candidate in reversed(list(enumerate(candidates))):
193 print(' processing candidate #%d... ' % (i + 1), end='') 193 print(' processing candidate #%d... ' % (i + 1), end='')
194 194
195 spec = candidate.get_rolled_spec() 195 spec = candidate.get_rolled_spec()
196 config_file.write(spec.dump()) 196 config_file.write(spec.dump())
197 fetch(context.repo_root, package_spec) 197 fetch(context.repo_root, package_spec)
198 write_new_recipes_py(context, spec, repo_cfg_block) 198 write_new_recipes_py(context, spec, repo_cfg_block)
199 199
200 rc, output = run_simulation_test( 200 rc, output = run_simulation_test(
201 context.repo_root, package_spec, ['--train']) 201 context.repo_root, package_spec, ['train'])
202 roll_details[i]['recipes_simulation_test_train'] = { 202 roll_details[i]['recipes_simulation_test_train'] = {
203 'output': output, 203 'output': output,
204 'rc': rc, 204 'rc': rc,
205 } 205 }
206 206
207 if rc == 0: 207 if rc == 0:
208 print('SUCCESS!') 208 print('SUCCESS!')
209 trivial = False 209 trivial = False
210 picked_roll_details = roll_details[i] 210 picked_roll_details = roll_details[i]
211 break 211 break
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 261
262 results = {} 262 results = {}
263 try: 263 try:
264 results = test_rolls( 264 results = test_rolls(
265 config_file, context, package_spec, args.projects or []) 265 config_file, context, package_spec, args.projects or [])
266 finally: 266 finally:
267 if not results.get('success'): 267 if not results.get('success'):
268 # Restore initial state. Since we could be running simulation tests 268 # Restore initial state. Since we could be running simulation tests
269 # on other revisions, re-run them now as well. 269 # on other revisions, re-run them now as well.
270 config_file.write(package_spec.dump()) 270 config_file.write(package_spec.dump())
271 run_simulation_test(context.repo_root, package_spec, ['--train'], 271 run_simulation_test(context.repo_root, package_spec, ['train'],
272 allow_fetch=True) 272 allow_fetch=True)
273 273
274 if args.output_json: 274 if args.output_json:
275 with open(args.output_json, 'w') as f: 275 with open(args.output_json, 'w') as f:
276 json.dump( 276 json.dump(
277 results, f, default=default_json_encode, sort_keys=True, indent=4) 277 results, f, default=default_json_encode, sort_keys=True, indent=4)
278 278
279 return 0 279 return 0
OLDNEW
« no previous file with comments | « no previous file | recipe_engine/test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698