mbed test: add argument `--ignore` to allow passing in extra mbedignore args

In particular this allows ignoring a project main.cpp file when running unit tests
pull/6833/head
Andrew Leech 2018-05-07 17:48:06 +10:00
parent 68ad00ffb8
commit badd753466
3 changed files with 21 additions and 5 deletions

View File

@ -502,7 +502,7 @@ def build_project(src_paths, build_path, target, toolchain_name,
notify=None, name=None, macros=None, inc_dirs=None, jobs=1,
report=None, properties=None, project_id=None,
project_description=None, config=None,
app_config=None, build_profile=None, stats_depth=None):
app_config=None, build_profile=None, stats_depth=None, ignore=None):
""" Build a project. A project may be a test or a user program.
Positional arguments:
@ -529,6 +529,7 @@ def build_project(src_paths, build_path, target, toolchain_name,
app_config - location of a chosen mbed_app.json file
build_profile - a dict of flags that will be passed to the compiler
stats_depth - depth level for memap to display file/dirs
ignore - list of paths to add to mbedignore
"""
# Convert src_path to a list if needed
@ -548,6 +549,10 @@ def build_project(src_paths, build_path, target, toolchain_name,
clean=clean, jobs=jobs, notify=notify, config=config,
app_config=app_config, build_profile=build_profile)
if ignore:
toolchain.add_ignore_patterns(root=".", base_path=".",
patterns=ignore)
# The first path will give the name to the library
name = (name or toolchain.config.name or
basename(normpath(abspath(src_paths[0]))))
@ -643,7 +648,7 @@ def build_library(src_paths, build_path, target, toolchain_name,
archive=True, notify=None, macros=None, inc_dirs=None, jobs=1,
report=None, properties=None, project_id=None,
remove_config_header_file=False, app_config=None,
build_profile=None):
build_profile=None, ignore=None):
""" Build a library
Positional arguments:
@ -668,6 +673,7 @@ def build_library(src_paths, build_path, target, toolchain_name,
remove_config_header_file - delete config header file when done building
app_config - location of a chosen mbed_app.json file
build_profile - a dict of flags that will be passed to the compiler
ignore - list of paths to add to mbedignore
"""
# Convert src_path to a list if needed
@ -693,6 +699,10 @@ def build_library(src_paths, build_path, target, toolchain_name,
clean=clean, jobs=jobs, notify=notify, app_config=app_config,
build_profile=build_profile)
if ignore:
toolchain.add_ignore_patterns(root=".", base_path=".",
patterns=ignore)
# The first path will give the name to the library
if name is None:
name = basename(normpath(abspath(src_paths[0])))

View File

@ -112,6 +112,9 @@ if __name__ == '__main__':
default=2,
help="Depth level for static memory report")
parser.add_argument("--ignore", dest="ignore", type=argparse_many(str),
default=None, help="Comma separated list of patterns to add to mbedignore (eg. ./main.cpp)")
options = parser.parse_args()
# Filter tests by path if specified
@ -153,6 +156,7 @@ if __name__ == '__main__':
if not config:
config = get_default_config(options.source_dir or ['.'], mcu)
# Find all tests in the relevant paths
for path in all_paths:
all_tests.update(find_tests(path, mcu, toolchain,
@ -205,7 +209,8 @@ if __name__ == '__main__':
macros=options.macros,
notify=notify, archive=False,
app_config=config,
build_profile=profile)
build_profile=profile,
ignore=options.ignore)
library_build_success = True
except ToolException as e:
@ -233,7 +238,8 @@ if __name__ == '__main__':
continue_on_build_fail=options.continue_on_build_fail,
app_config=config,
build_profile=profile,
stats_depth=options.stats_depth)
stats_depth=options.stats_depth,
ignore=options.ignore)
# If a path to a test spec is provided, write it to a file
if options.test_spec:

View File

@ -2210,7 +2210,7 @@ def build_tests(tests, base_source_paths, build_path, target, toolchain_name,
clean=False, notify=None, jobs=1, macros=None,
silent=False, report=None, properties=None,
continue_on_build_fail=False, app_config=None,
build_profile=None, stats_depth=None):
build_profile=None, stats_depth=None, ignore=None):
"""Given the data structure from 'find_tests' and the typical build parameters,
build all the tests