mirror of https://github.com/ARMmbed/mbed-os.git
Correct test_name_known, now use argparse_many for lists
also updated all consumers of test_name_knownpull/2010/head
parent
5052e97b17
commit
b4b514ea2f
|
@ -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")
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue