Skip to content

Commit b4b514e

Browse files
committed
Correct test_name_known, now use argparse_many for lists
also updated all consumers of test_name_known
1 parent 5052e97 commit b4b514e

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

tools/make.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,19 +44,20 @@
4444
from tools.build_api import build_project
4545
from tools.build_api import mcu_toolchain_matrix
4646
from utils import argparse_filestring_type
47+
from utils import argparse_many
4748
from argparse import ArgumentTypeError
4849

4950
if __name__ == '__main__':
5051
# Parse Options
5152
parser = get_default_options_parser()
5253
group = parser.add_mutually_exclusive_group(required=True)
5354
group.add_argument("-p",
54-
type=test_known,
55+
type=argparse_many(test_known),
5556
dest="program",
5657
help="The index of the desired test program: [0-%d]" % (len(TESTS)-1))
5758

5859
group.add_argument("-n",
59-
type=test_name_known,
60+
type=argparse_many(test_name_known),
6061
dest="program",
6162
help="The name of the desired test program")
6263

tools/tests.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1234,11 +1234,9 @@ def test_known(string):
12341234
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)])))
12351235

12361236
def test_name_known(string):
1237-
nlist = string.split(',')
1238-
for test_id in nlist:
1239-
if test_id not in TEST_MAP.keys():
1240-
if getattr(ps, "test_alias", None) is None or \
1241-
ps.test_alias.get(test_id, "") not in TEST_MAP.keys():
1242-
raise ArgumentTypeError("Program with name '{0}' not found. Supported tests are: \n{1}".format(test_id, columnate([t['id'] for t in TESTS])))
1237+
if string not in TEST_MAP.keys() and \
1238+
(getattr(ps, "test_alias", None) is None or \
1239+
ps.test_alias.get(test_id, "") not in TEST_MAP.keys()):
1240+
raise ArgumentTypeError("Program with name '{0}' not found. Supported tests are: \n{1}".format(string, columnate([t['id'] for t in TESTS])))
12431241

1244-
return [TEST_MAP[n].n for n in nlist]
1242+
return TEST_MAP[string].n

0 commit comments

Comments
 (0)