-
Notifications
You must be signed in to change notification settings - Fork 179
Feature: Macros handling to mbed test
#835
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -1760,11 +1760,12 @@ def set_defaults(self, target=None, toolchain=None): | |||||||||||||||
if toolchain and not self.get_cfg('TOOLCHAIN'): | ||||||||||||||||
self.set_cfg('TOOLCHAIN', toolchain) | ||||||||||||||||
|
||||||||||||||||
def get_macros(self): | ||||||||||||||||
macros = [] | ||||||||||||||||
def get_macros(self, more_macros=None): | ||||||||||||||||
macros = more_macros or [] | ||||||||||||||||
# backwards compatibility with old MACROS.txt file | ||||||||||||||||
if os.path.isfile('MACROS.txt'): | ||||||||||||||||
with open('MACROS.txt') as f: | ||||||||||||||||
macros = f.read().splitlines() | ||||||||||||||||
macros.extend(f.read().splitlines()) | ||||||||||||||||
return macros | ||||||||||||||||
|
||||||||||||||||
|
||||||||||||||||
|
@@ -2613,6 +2614,7 @@ def _safe_append_profile_to_build_path(build_path, profile): | |||||||||||||||
@subcommand('compile', | ||||||||||||||||
dict(name=['-t', '--toolchain'], help='Compile toolchain. Example: ARM, GCC_ARM, IAR'), | ||||||||||||||||
dict(name=['-m', '--target'], help='Compile target MCU. Example: K64F, NUCLEO_F401RE, NRF51822...'), | ||||||||||||||||
dict(name=['-D', '--macro'], action='append', help='Add a macro definition'), | ||||||||||||||||
dict(name=['--profile'], action='append', help='Path of a build profile configuration file (or name of Mbed OS profile). Default: develop'), | ||||||||||||||||
dict(name='--library', dest='compile_library', action='store_true', help='Compile the current program or library as a static library.'), | ||||||||||||||||
dict(name='--config', dest='compile_config', action='store_true', help='Show run-time compile configuration'), | ||||||||||||||||
|
@@ -2627,7 +2629,10 @@ def _safe_append_profile_to_build_path(build_path, profile): | |||||||||||||||
dict(name='--app-config', dest="app_config", help="Path of an application configuration file. Default is to look for \"mbed_app.json\"."), | ||||||||||||||||
help='Compile code using the mbed build tools', | ||||||||||||||||
description="Compile this program using the mbed build tools.") | ||||||||||||||||
def compile_(toolchain=None, target=None, profile=False, compile_library=False, compile_config=False, config_prefix=None, source=False, build=False, clean=False, flash=False, sterm=False, artifact_name=None, supported=False, app_config=None): | ||||||||||||||||
def compile_(toolchain=None, target=None, macro=False, profile=False, | ||||||||||||||||
compile_library=False, compile_config=False, config_prefix=None, | ||||||||||||||||
source=False, build=False, clean=False, flash=False, sterm=False, | ||||||||||||||||
artifact_name=None, supported=False, app_config=None): | ||||||||||||||||
# Gather remaining arguments | ||||||||||||||||
args = remainder | ||||||||||||||||
# Find the root of the program | ||||||||||||||||
|
@@ -2656,7 +2661,7 @@ def compile_(toolchain=None, target=None, profile=False, compile_library=False, | |||||||||||||||
|
||||||||||||||||
target = program.get_target(target) | ||||||||||||||||
tchain = program.get_toolchain(toolchain) | ||||||||||||||||
macros = program.get_macros() | ||||||||||||||||
macros = program.get_macros(macro) | ||||||||||||||||
profile = program.get_profile(profile) | ||||||||||||||||
|
||||||||||||||||
if compile_config: | ||||||||||||||||
|
@@ -2750,6 +2755,7 @@ def compile_(toolchain=None, target=None, profile=False, compile_library=False, | |||||||||||||||
@subcommand('test', | ||||||||||||||||
dict(name=['-t', '--toolchain'], help='Compile toolchain. Example: ARM, GCC_ARM, IAR'), | ||||||||||||||||
dict(name=['-m', '--target'], help='Compile target MCU. Example: K64F, NUCLEO_F401RE, NRF51822...'), | ||||||||||||||||
dict(name=['-D', '--macro'], action='append', help='Add a macro definition'), | ||||||||||||||||
dict(name='--compile-list', dest='compile_list', action='store_true', | ||||||||||||||||
help='List all tests that can be built'), | ||||||||||||||||
dict(name='--run-list', dest='run_list', action='store_true', help='List all built tests that can be ran'), | ||||||||||||||||
|
@@ -2777,12 +2783,7 @@ def compile_(toolchain=None, target=None, profile=False, compile_library=False, | |||||||||||||||
help="Run Icetea tests. If used without --greentea flag then run only icetea tests."), | ||||||||||||||||
help='Find, build and run tests', | ||||||||||||||||
description="Find, build, and run tests in a program and libraries") | ||||||||||||||||
def test_(toolchain=None, target=None, compile_list=False, run_list=False, | ||||||||||||||||
compile_only=False, run_only=False, tests_by_name=None, source=False, | ||||||||||||||||
profile=False, build=False, clean=False, test_spec=None, | ||||||||||||||||
app_config=None, test_config=None, coverage=None, make_program=None, | ||||||||||||||||
new=None, generator=None, regex=None, unittests=None, | ||||||||||||||||
build_data=None, greentea=None, icetea=None): | ||||||||||||||||
def test_(toolchain=None, target=None, macro=False, compile_list=False, run_list=False, compile_only=False, run_only=False, tests_by_name=None, source=False, profile=False, build=False, clean=False, test_spec=None, app_config=None, test_config=None, coverage=None, make_program=None, new=None, generator=None, regex=None, unittests=None, build_data=None, greentea=None, icetea=None): | ||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||
|
||||||||||||||||
# Default behaviour is to run only greentea tests | ||||||||||||||||
if not (greentea or icetea or unittests): | ||||||||||||||||
|
@@ -2808,7 +2809,8 @@ def test_(toolchain=None, target=None, compile_list=False, run_list=False, | |||||||||||||||
orig_path = getcwd() | ||||||||||||||||
orig_target = target | ||||||||||||||||
|
||||||||||||||||
macros = program.get_macros() | ||||||||||||||||
macros = program.get_macros(macro) | ||||||||||||||||
macros.append("MBED_TEST_MODE") | ||||||||||||||||
theotherjimmy marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||
tools_dir = program.get_tools() | ||||||||||||||||
build_and_run_tests = not compile_list and not run_list and not compile_only and not run_only | ||||||||||||||||
|
||||||||||||||||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EDIT: oh dear, this is a bad idea, please ignore. Thanks @theotherjimmy
nitpick/simplification: You can simplify this block by altering the function:This allows you to remove this lineThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bridadan please don't suggest this. https://docs.python-guide.org/writing/gotchas/#mutable-default-arguments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That being said, please change
False
toNone
, as it's the pythonic "value is missing" value.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yikes, thanks for the heads up. I learned something today.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bridadan see Jimmy's comment and also the extra commit. I had it before the way you suggested :)