Move test parsers to tests.py

pull/1976/head
Jimmy Brisson 2016-06-21 13:59:28 -05:00
parent b98c8c1c33
commit e4c6bcd724
2 changed files with 23 additions and 17 deletions

View File

@ -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

View File

@ -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]