Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of mbed-sdk-tools by
Diff: test.py
- Revision:
- 32:8ea194f6145b
- Parent:
- 30:f12ce67666d0
diff -r f12ce67666d0 -r 8ea194f6145b test.py --- a/test.py Mon Aug 29 11:56:59 2016 +0100 +++ b/test.py Wed Jan 04 11:58:24 2017 -0600 @@ -26,8 +26,9 @@ ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) sys.path.insert(0, ROOT) +from tools.config import ConfigException from tools.test_api import test_path_to_name, find_tests, print_tests, build_tests, test_spec_from_test_builds -from tools.options import get_default_options_parser +from tools.options import get_default_options_parser, extract_profile from tools.build_api import build_project, build_library from tools.build_api import print_build_memory_usage from tools.targets import TARGET_MAP @@ -35,13 +36,13 @@ from tools.test_exporters import ReportExporter, ResultExporterType from utils import argparse_filestring_type, argparse_lowercase_type, argparse_many from utils import argparse_dir_not_parent -from tools.toolchains import mbedToolchain +from tools.toolchains import mbedToolchain, TOOLCHAIN_PATHS, TOOLCHAIN_CLASSES from tools.settings import CLI_COLOR_MAP if __name__ == '__main__': try: # Parse Options - parser = get_default_options_parser() + parser = get_default_options_parser(add_app_config=True) parser.add_argument("-D", action="append", @@ -107,17 +108,24 @@ # Target if options.mcu is None : - args_error(parser, "[ERROR] You should specify an MCU") + args_error(parser, "argument -m/--mcu is required") mcu = options.mcu[0] # Toolchain if options.tool is None: - args_error(parser, "[ERROR] You should specify a TOOLCHAIN") + args_error(parser, "argument -t/--tool is required") toolchain = options.tool[0] + if not TOOLCHAIN_CLASSES[toolchain].check_executable(): + search_path = TOOLCHAIN_PATHS[toolchain] or "No path set" + args_error(parser, "Could not find executable for %s.\n" + "Currently set search path: %s" + % (toolchain, search_path)) + # Find all tests in the relevant paths for path in all_paths: - all_tests.update(find_tests(path, mcu, toolchain, options.options)) + all_tests.update(find_tests(path, mcu, toolchain, + app_config=options.app_config)) # Filter tests by name if specified if options.names: @@ -152,8 +160,7 @@ else: # Build all tests if not options.build_dir: - print "[ERROR] You must specify a build path" - sys.exit(1) + args_error(parser, "argument --build is required") base_source_paths = options.source_dir @@ -165,10 +172,10 @@ build_properties = {} library_build_success = False + profile = extract_profile(parser, options, toolchain) try: # Build sources build_library(base_source_paths, options.build_dir, mcu, toolchain, - options=options.options, jobs=options.jobs, clean=options.clean, report=build_report, @@ -177,7 +184,9 @@ macros=options.macros, verbose=options.verbose, notify=notify, - archive=False) + archive=False, + app_config=options.app_config, + build_profile=profile) library_build_success = True except ToolException, e: @@ -194,8 +203,8 @@ print "Failed to build library" else: # Build all the tests + test_build_success, test_build = build_tests(tests, [options.build_dir], options.build_dir, mcu, toolchain, - options=options.options, clean=options.clean, report=build_report, properties=build_properties, @@ -203,7 +212,9 @@ verbose=options.verbose, notify=notify, jobs=options.jobs, - continue_on_build_fail=options.continue_on_build_fail) + continue_on_build_fail=options.continue_on_build_fail, + app_config=options.app_config, + build_profile=profile) # If a path to a test spec is provided, write it to a file if options.test_spec: @@ -242,6 +253,9 @@ except KeyboardInterrupt, e: print "\n[CTRL+c] exit" + except ConfigException, e: + # Catching ConfigException here to prevent a traceback + print "[ERROR] %s" % str(e) except Exception,e: import traceback traceback.print_exc(file=sys.stdout)