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

Side by Side Diff: recipe_engine/autoroll.py

Issue 2841373002: [autoroll] add tests for autoroll subcommand parsing. (Closed)
Patch Set: vendored argparse 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 argparse
7 import copy 8 import copy
8 import json 9 import json
9 import logging 10 import logging
10 import os 11 import os
11 import subprocess 12 import subprocess
12 import sys 13 import sys
13 import time 14 import time
14 15
15 from collections import namedtuple 16 from collections import namedtuple
16 17
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 package_io.dump_obj(c.package_pb) for c in rejected_candidates] 267 package_io.dump_obj(c.package_pb) for c in rejected_candidates]
267 return ret 268 return ret
268 269
269 270
270 def add_subparser(parser): 271 def add_subparser(parser):
271 helpstr = 'Roll dependencies of a recipe package forward.' 272 helpstr = 'Roll dependencies of a recipe package forward.'
272 autoroll_p = parser.add_parser( 273 autoroll_p = parser.add_parser(
273 'autoroll', help=helpstr, description=helpstr) 274 'autoroll', help=helpstr, description=helpstr)
274 autoroll_p.add_argument( 275 autoroll_p.add_argument(
275 '--output-json', 276 '--output-json',
276 type=os.path.abspath, 277 type=argparse.FileType('w'),
dnj 2017/04/27 17:19:03 I think we should explicitly close this when we're
iannucci 2017/04/29 18:30:56 Done.
277 help='A json file to output information about the roll to.') 278 help='A json file to output information about the roll to.')
278 autoroll_p.add_argument( 279 autoroll_p.add_argument(
279 '--verbose-json', 280 '--verbose-json',
280 action='store_true', 281 action='store_true',
281 help=('Emit even more data in the output-json file. ' 282 help=('Emit even more data in the output-json file. '
282 'Requires --output-json.')) 283 'Requires --output-json.'))
283 284
284 def postprocess_func(parser, args): 285 def postprocess_func(parser, args):
285 if args.no_fetch: 286 if args.no_fetch:
286 parser.error('autoroll with --no-fetch does not make sense.') 287 parser.error('autoroll with --no-fetch does not make sense.')
(...skipping 24 matching lines...) Expand all
311 results = test_rolls( 312 results = test_rolls(
312 repo_cfg_block, config_file, context, package_spec, args.verbose_json) 313 repo_cfg_block, config_file, context, package_spec, args.verbose_json)
313 finally: 314 finally:
314 if not results.get('success'): 315 if not results.get('success'):
315 # Restore initial state. Since we could be running simulation tests 316 # Restore initial state. Since we could be running simulation tests
316 # on other revisions, re-run them now as well. 317 # on other revisions, re-run them now as well.
317 write_spec_to_disk(context, repo_cfg_block, config_file, package_pb) 318 write_spec_to_disk(context, repo_cfg_block, config_file, package_pb)
318 run_simulation_test(repo_root, package_spec.recipes_path, ['train']) 319 run_simulation_test(repo_root, package_spec.recipes_path, ['train'])
319 320
320 if args.output_json: 321 if args.output_json:
321 with open(args.output_json, 'w') as f: 322 json.dump(results, args.output_json, sort_keys=True, indent=2)
322 json.dump(results, f, sort_keys=True, indent=2)
323 323
324 return 0 324 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