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

Side by Side Diff: recipe_engine/autoroll.py

Issue 2841373002: [autoroll] add tests for autoroll subcommand parsing. (Closed)
Patch Set: close file Created 3 years, 7 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/unittests/autoroll_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 copy 7 import copy
8 import json 8 import json
9 import logging 9 import logging
10 import os 10 import os
11 import subprocess 11 import subprocess
12 import sys 12 import sys
13 import time 13 import time
14 14
15 from collections import namedtuple 15 from collections import namedtuple
16 16
17 from . import package 17 from . import package
18 from . import package_io 18 from . import package_io
19 from .autoroll_impl.candidate_algorithm import get_roll_candidates 19 from .autoroll_impl.candidate_algorithm import get_roll_candidates
20 20
21 from . import env
22
23 import argparse # this is vendored
24
21 25
22 LOGGER = logging.getLogger(__name__) 26 LOGGER = logging.getLogger(__name__)
23 27
24 ROOT_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), '..') 28 ROOT_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), '..')
25 29
26 30
27 # This is the path within the recipes-py repo to the per-repo recipes.py script. 31 # This is the path within the recipes-py repo to the per-repo recipes.py script.
28 # Ideally we'd read this somehow from each candidate engine repo version, but 32 # Ideally we'd read this somehow from each candidate engine repo version, but
29 # for now assume it lives in a fixed location within the engine. 33 # for now assume it lives in a fixed location within the engine.
30 RECIPES_PY_REL_PATH = ('doc', 'recipes.py') 34 RECIPES_PY_REL_PATH = ('doc', 'recipes.py')
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 package_io.dump_obj(c.package_pb) for c in rejected_candidates] 270 package_io.dump_obj(c.package_pb) for c in rejected_candidates]
267 return ret 271 return ret
268 272
269 273
270 def add_subparser(parser): 274 def add_subparser(parser):
271 helpstr = 'Roll dependencies of a recipe package forward.' 275 helpstr = 'Roll dependencies of a recipe package forward.'
272 autoroll_p = parser.add_parser( 276 autoroll_p = parser.add_parser(
273 'autoroll', help=helpstr, description=helpstr) 277 'autoroll', help=helpstr, description=helpstr)
274 autoroll_p.add_argument( 278 autoroll_p.add_argument(
275 '--output-json', 279 '--output-json',
276 type=os.path.abspath, 280 type=argparse.FileType('w'),
277 help='A json file to output information about the roll to.') 281 help='A json file to output information about the roll to.')
278 autoroll_p.add_argument( 282 autoroll_p.add_argument(
279 '--verbose-json', 283 '--verbose-json',
280 action='store_true', 284 action='store_true',
281 help=('Emit even more data in the output-json file. ' 285 help=('Emit even more data in the output-json file. '
282 'Requires --output-json.')) 286 'Requires --output-json.'))
283 287
284 def postprocess_func(parser, args): 288 def postprocess_func(parser, args):
285 if args.no_fetch: 289 if args.no_fetch:
286 parser.error('autoroll with --no-fetch does not make sense.') 290 parser.error('autoroll with --no-fetch does not make sense.')
(...skipping 24 matching lines...) Expand all
311 results = test_rolls( 315 results = test_rolls(
312 repo_cfg_block, config_file, context, package_spec, args.verbose_json) 316 repo_cfg_block, config_file, context, package_spec, args.verbose_json)
313 finally: 317 finally:
314 if not results.get('success'): 318 if not results.get('success'):
315 # Restore initial state. Since we could be running simulation tests 319 # Restore initial state. Since we could be running simulation tests
316 # on other revisions, re-run them now as well. 320 # on other revisions, re-run them now as well.
317 write_spec_to_disk(context, repo_cfg_block, config_file, package_pb) 321 write_spec_to_disk(context, repo_cfg_block, config_file, package_pb)
318 run_simulation_test(repo_root, package_spec.recipes_path, ['train']) 322 run_simulation_test(repo_root, package_spec.recipes_path, ['train'])
319 323
320 if args.output_json: 324 if args.output_json:
321 with open(args.output_json, 'w') as f: 325 with args.output_json:
322 json.dump(results, f, sort_keys=True, indent=2) 326 json.dump(results, args.output_json, sort_keys=True, indent=2)
323 327
324 return 0 328 return 0
OLDNEW
« no previous file with comments | « no previous file | recipe_engine/unittests/autoroll_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698