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

Side by Side Diff: recipes.py

Issue 2061263003: add basic bootstrap for coverage (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/recipes-py@master
Patch Set: Add recipes.py flag. Created 4 years, 6 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
« bootstrap/bootstrap.py ('K') | « bootstrap/util.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2015 The LUCI Authors. All rights reserved. 2 # Copyright 2015 The LUCI Authors. All rights reserved.
3 # Use of this source code is governed under the Apache License, Version 2.0 3 # Use of this source code is governed under the Apache License, Version 2.0
4 # that can be found in the LICENSE file. 4 # that can be found in the LICENSE file.
5 5
6 """Tool to interact with recipe repositories. 6 """Tool to interact with recipe repositories.
7 7
8 This tool operates on the nearest ancestor directory containing an 8 This tool operates on the nearest ancestor directory containing an
9 infra/config/recipes.cfg. 9 infra/config/recipes.cfg.
10 """ 10 """
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 def info(args): 211 def info(args):
212 from recipe_engine import package 212 from recipe_engine import package
213 repo_root, config_file = get_package_config(args) 213 repo_root, config_file = get_package_config(args)
214 package_spec = package.PackageSpec.load_proto(config_file) 214 package_spec = package.PackageSpec.load_proto(config_file)
215 215
216 if args.recipes_dir: 216 if args.recipes_dir:
217 print package_spec.recipes_path 217 print package_spec.recipes_path
218 218
219 219
220 def main(): 220 def main():
221 sysargs = sys.argv
Paweł Hajdan Jr. 2016/06/15 10:56:19 What's the intention of this code? It doesn't see
martiniss 2016/06/15 20:36:53 I moved this to where we mutate sys.argv, and made
221 from recipe_engine import package 222 from recipe_engine import package
222 223
223 # Super-annoyingly, we need to manually parse for simulation_test since 224 # Super-annoyingly, we need to manually parse for simulation_test since
224 # argparse is bonkers and doesn't allow us to forward --help to subcommands. 225 # argparse is bonkers and doesn't allow us to forward --help to subcommands.
225 if 'simulation_test' in sys.argv: 226 if 'simulation_test' in sys.argv:
226 index = sys.argv.index('simulation_test') 227 index = sys.argv.index('simulation_test')
227 sys.argv = sys.argv[:index+1] + [json.dumps(sys.argv[index+1:])] 228 sys.argv = sys.argv[:index+1] + [json.dumps(sys.argv[index+1:])]
228 229
229 parser = argparse.ArgumentParser( 230 parser = argparse.ArgumentParser(
230 description='Interact with the recipe system.') 231 description='Interact with the recipe system.')
(...skipping 11 matching lines...) Expand all
242 # TODO(phajdan.jr): Figure out if we need --no-fetch; remove if not. 243 # TODO(phajdan.jr): Figure out if we need --no-fetch; remove if not.
243 parser.add_argument( 244 parser.add_argument(
244 '--no-fetch', action='store_true', 245 '--no-fetch', action='store_true',
245 help='Disable automatic fetching') 246 help='Disable automatic fetching')
246 parser.add_argument( 247 parser.add_argument(
247 '--bootstrap-script', 248 '--bootstrap-script',
248 help='Path to the script used to bootstrap this tool (internal use only)') 249 help='Path to the script used to bootstrap this tool (internal use only)')
249 parser.add_argument('-O', '--project-override', metavar='ID=PATH', 250 parser.add_argument('-O', '--project-override', metavar='ID=PATH',
250 action=ProjectOverrideAction, 251 action=ProjectOverrideAction,
251 help='Override a project repository path with a local one.') 252 help='Override a project repository path with a local one.')
253 parser.add_argument(
254 '--use-bootstrap', action='store_true',
255 help='Use bootstrap/bootstrap.py to create a isolated python virtualenv'
256 ' with required python dependencies.')
252 257
253 subp = parser.add_subparsers() 258 subp = parser.add_subparsers()
254 259
255 fetch_p = subp.add_parser( 260 fetch_p = subp.add_parser(
256 'fetch', 261 'fetch',
257 description='Fetch and update dependencies.') 262 description='Fetch and update dependencies.')
258 fetch_p.set_defaults(command='fetch') 263 fetch_p.set_defaults(command='fetch')
259 264
260 simulation_test_p = subp.add_parser( 265 simulation_test_p = subp.add_parser(
261 'simulation_test', 266 'simulation_test',
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 info_p = subp.add_parser( 374 info_p = subp.add_parser(
370 'info', 375 'info',
371 description='Query information about the current recipe package') 376 description='Query information about the current recipe package')
372 info_p.set_defaults(command='info') 377 info_p.set_defaults(command='info')
373 info_p.add_argument( 378 info_p.add_argument(
374 '--recipes-dir', action='store_true', 379 '--recipes-dir', action='store_true',
375 help='Get the subpath where the recipes live relative to repository root') 380 help='Get the subpath where the recipes live relative to repository root')
376 381
377 args = parser.parse_args() 382 args = parser.parse_args()
378 383
384 if args.use_bootstrap:
385 subprocess.check_call(
386 ['bootstrap/bootstrap.py', '--deps-file', 'bootstrap/deps.pyl', 'ENV'],
Paweł Hajdan Jr. 2016/06/15 10:56:19 nit: Start with sys.executable .
martiniss 2016/06/15 20:36:53 Done.
387 cwd=os.path.dirname(os.path.realpath(__file__)))
388
389 args = [arg for arg in sysargs[1:] if 'use-bootstrap' not in arg]
Paweł Hajdan Jr. 2016/06/15 10:56:19 nit: This might interfere with other legitimate ar
martiniss 2016/06/15 20:36:53 I used an environment variable, like update script
390 return subprocess.call(
391 ['ENV/bin/python', 'recipes.py'] + args,
392 cwd=os.path.dirname(os.path.realpath(__file__)))
393
379 if args.verbose: 394 if args.verbose:
380 logging.getLogger().setLevel(logging.INFO) 395 logging.getLogger().setLevel(logging.INFO)
381 396
382 # Commands which do not require config_file, package_deps, and other objects 397 # Commands which do not require config_file, package_deps, and other objects
383 # initialized later. 398 # initialized later.
384 if args.command == 'remote_run': 399 if args.command == 'remote_run':
385 return remote_run(args) 400 return remote_run(args)
386 401
387 repo_root, config_file = get_package_config(args) 402 repo_root, config_file = get_package_config(args)
388 403
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 ret = main() 458 ret = main()
444 if not isinstance(ret, int): 459 if not isinstance(ret, int):
445 if ret is None: 460 if ret is None:
446 ret = 0 461 ret = 0
447 else: 462 else:
448 print >> sys.stderr, ret 463 print >> sys.stderr, ret
449 ret = 1 464 ret = 1
450 sys.stdout.flush() 465 sys.stdout.flush()
451 sys.stderr.flush() 466 sys.stderr.flush()
452 os._exit(ret) 467 os._exit(ret)
OLDNEW
« bootstrap/bootstrap.py ('K') | « bootstrap/util.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698