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

Side by Side Diff: recipe_engine/test.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 | « recipe_engine/autoroll.py ('k') | unittests/repo_test_util.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 2017 The LUCI Authors. All rights reserved. 1 # Copyright 2017 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 argparse
8 import bdb 8 import bdb
9 import cStringIO 9 import cStringIO
10 import contextlib 10 import contextlib
(...skipping 714 matching lines...) Expand 10 before | Expand all | Expand 10 after
725 run_p.add_argument( 725 run_p.add_argument(
726 '--json', metavar='FILE', type=argparse.FileType('w'), 726 '--json', metavar='FILE', type=argparse.FileType('w'),
727 help='path to JSON output file') 727 help='path to JSON output file')
728 run_p.add_argument( 728 run_p.add_argument(
729 '--filter', action='append', 729 '--filter', action='append',
730 help='glob filter for the tests to run; ' 730 help='glob filter for the tests to run; '
731 'can be specified multiple times; ' 731 'can be specified multiple times; '
732 'the globs have the form of ' 732 'the globs have the form of '
733 '`<recipe_name_glob>[.<test_name_glob>]`. If `.<test_name_glob>` ' 733 '`<recipe_name_glob>[.<test_name_glob>]`. If `.<test_name_glob>` '
734 'is omitted, it is implied to be `.*`, i.e. all tests.)') 734 'is omitted, it is implied to be `.*`, i.e. all tests.)')
735 # TODO(phajdan.jr): remove --train the switch in favor of train subcommand.
735 run_p.add_argument( 736 run_p.add_argument(
736 '--train', action='store_true', 737 '--train', action='store_true',
737 help='re-generate recipe expectations') 738 help='re-generate recipe expectations (DEPRECATED)')
739
740 train_p = subp.add_parser('train', description='Re-train recipe expectations')
741 train_p.set_defaults(func=lambda opts: run_run(
742 opts.filter, jobs=opts.jobs, json_file=opts.json, train=True))
743 train_p.add_argument(
744 '--jobs', metavar='N', type=int,
745 default=multiprocessing.cpu_count(),
746 help='run N jobs in parallel (default %(default)s)')
747 train_p.add_argument(
748 '--json', metavar='FILE', type=argparse.FileType('w'),
749 help='path to JSON output file')
750 train_p.add_argument(
751 '--filter', action='append',
752 help='glob filter for the tests to run; '
753 'can be specified multiple times; '
754 'the globs have the form of '
755 '`<recipe_name_glob>[.<test_name_glob>]`. If `.<test_name_glob>` '
756 'is omitted, it is implied to be `.*`, i.e. all tests.)')
738 757
739 debug_p = subp.add_parser( 758 debug_p = subp.add_parser(
740 'debug', description='Run the tests under debugger (pdb)') 759 'debug', description='Run the tests under debugger (pdb)')
741 debug_p.set_defaults(func=lambda opts: run_run( 760 debug_p.set_defaults(func=lambda opts: run_run(
742 opts.filter, debug=True)) 761 opts.filter, debug=True))
743 debug_p.add_argument( 762 debug_p.add_argument(
744 '--filter', action='append', 763 '--filter', action='append',
745 help='glob filter for the tests to run; ' 764 help='glob filter for the tests to run; '
746 'can be specified multiple times; ' 765 'can be specified multiple times; '
747 'the globs have the form of ' 766 'the globs have the form of '
(...skipping 24 matching lines...) Expand all
772 Returns: 791 Returns:
773 Exit code 792 Exit code
774 """ 793 """
775 global _UNIVERSE_VIEW 794 global _UNIVERSE_VIEW
776 _UNIVERSE_VIEW = universe_view 795 _UNIVERSE_VIEW = universe_view
777 global _ENGINE_FLAGS 796 global _ENGINE_FLAGS
778 _ENGINE_FLAGS = engine_flags 797 _ENGINE_FLAGS = engine_flags
779 798
780 args = parse_args(raw_args) 799 args = parse_args(raw_args)
781 return args.func(args) 800 return args.func(args)
OLDNEW
« no previous file with comments | « recipe_engine/autoroll.py ('k') | unittests/repo_test_util.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698