Correct test_name_known, now use argparse_many for lists

also updated all consumers of test_name_known
pull/2010/head
Jimmy Brisson 2016-06-28 19:58:02 -05:00
parent 5052e97b17
commit b4b514ea2f
2 changed files with 8 additions and 9 deletions

View File

@ -44,6 +44,7 @@ from tools.options import get_default_options_parser
from tools.build_api import build_project
from tools.build_api import mcu_toolchain_matrix
from utils import argparse_filestring_type
from utils import argparse_many
from argparse import ArgumentTypeError
if __name__ == '__main__':
@ -51,12 +52,12 @@ if __name__ == '__main__':
parser = get_default_options_parser()
group = parser.add_mutually_exclusive_group(required=True)
group.add_argument("-p",
type=test_known,
type=argparse_many(test_known),
dest="program",
help="The index of the desired test program: [0-%d]" % (len(TESTS)-1))
group.add_argument("-n",
type=test_name_known,
type=argparse_many(test_name_known),
dest="program",
help="The name of the desired test program")

View File

@ -1234,11 +1234,9 @@ def test_known(string):
raise ArgumentTypeError("{0} does not index a test. The accepted range is 0 to {1}\nThe test mapping is:\n{2}".format(i, len(TEST_MAP) - 1, columnate([str(i) + ":" + t['id'] for i,t in zip(range(len(TESTS)), TESTS)])))
def test_name_known(string):
nlist = string.split(',')
for test_id in nlist:
if test_id not in TEST_MAP.keys():
if getattr(ps, "test_alias", None) is None or \
ps.test_alias.get(test_id, "") not in TEST_MAP.keys():
raise ArgumentTypeError("Program with name '{0}' not found. Supported tests are: \n{1}".format(test_id, columnate([t['id'] for t in TESTS])))
if string not in TEST_MAP.keys() and \
(getattr(ps, "test_alias", None) is None or \
ps.test_alias.get(test_id, "") not in TEST_MAP.keys()):
raise ArgumentTypeError("Program with name '{0}' not found. Supported tests are: \n{1}".format(string, columnate([t['id'] for t in TESTS])))
return [TEST_MAP[n].n for n in nlist]
return TEST_MAP[string].n