diff --git a/tools/make.py b/tools/make.py index 431384168a..b19321923a 100644 --- a/tools/make.py +++ b/tools/make.py @@ -38,29 +38,13 @@ from tools.paths import FS_LIBRARY from tools.paths import UBLOX_LIBRARY from tools.tests import TESTS, Test, TEST_MAP from tools.tests import TEST_MBED_LIB +from tools.tests import test_known, test_name_known from tools.targets import TARGET_MAP 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 argparse import ArgumentTypeError -try: - import tools.private_settings as ps -except: - ps = object() - -def test_known(string): - i = int(string) - if i >= 0 and i < len(TESTS) : return i - else : raise ArgumentTypeError("{0} does not index a test".format(i)) - -def test_name_known(string): - nlist = string.split(',') - for test_id in nlist: - if test_id not in TEST_MAP.keys(): - raise ArgumentTypeError("Program with name '%s' not found"% test_id) - - return [TEST_MAP[n].n for n in nlist] if __name__ == '__main__': # Parse Options diff --git a/tools/tests.py b/tools/tests.py index 1b70f61e03..415fc14029 100644 --- a/tools/tests.py +++ b/tools/tests.py @@ -16,6 +16,12 @@ limitations under the License. """ from tools.paths import * from tools.data.support import * +from argparse import ArgumentTypeError + +try: + import tools.private_settings as ps +except: + ps = object() TEST_CMSIS_LIB = join(TEST_DIR, "cmsis", "lib") TEST_MBED_LIB = join(TEST_DIR, "mbed", "env") @@ -1212,3 +1218,19 @@ class Test: return None TEST_MAP = dict([(test['id'], Test(i)) for i, test in enumerate(TESTS)]) + +# parser helpers +def test_known(string): + i = int(string) + if i >= 0 and i < len(TESTS) : return i + else : raise ArgumentTypeError("{0} does not index a test".format(i)) + +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 '%s' not found"% test_id) + + return [TEST_MAP[n].n for n in nlist]