-
Notifications
You must be signed in to change notification settings - Fork 3k
Add test macro MBED_TEST when building with mbed test
#7627
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
Conversation
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.
Sweet!
tools/test.py
Outdated
if options.macros is None: | ||
options.macros = (['MBED_TEST']) | ||
else: | ||
options.macros.extend(['MBED_TEST']) |
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.
Nit: I realize I mentioned extend
in our offline talk, but you can also do options.macros.append('MBED_TEST')
if you want to avoid creating another list.
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.
Done
84e23a7
to
15565df
Compare
tools/test.py
Outdated
@@ -126,6 +126,12 @@ | |||
all_tests = {} | |||
tests = {} | |||
|
|||
# Add the test macro, when compiling all test | |||
if options.macros is None: | |||
options.macros = (['MBED_TEST']) |
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.
Why the ()
?
15565df
to
6a99b23
Compare
tools/test.py
Outdated
if options.macros is None: | ||
options.macros = ['MBED_TEST'] | ||
else: | ||
options.macros.append(['MBED_TEST']) |
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.
@deepikabhavnani this isn't right and will probably cause problems:
>>> a = [1, 2, 3]
>>> a.append([4])
>>> a
[1, 2, 3, [4]]
(Note the extra list)
It should be options.macros.append('MBED_TEST')
6a99b23
to
b9d3a3a
Compare
For what purposes is this used then? |
@deepikabhavnani Question from @SeppoTakalo |
@SeppoTakalo Does this PR answer your question? |
@cmonr not really. I was trying to ask what particular problem does this fix?
I'm always against adding more build rules into our already complex collection of Python build scripts. |
@SeppoTakalo - #7626 was the drive for the change, also I have added my points regarding why we should be having macro in comments.
This seems like good option, will like to hear from @ARMmbed/mbed-os-core @theotherjimmy @0xc0170 what they think of moving |
I believe the is no common folder in In future, we might even have more code that could be share between test cases. |
@SeppoTakalo There is a common folder in tests structure. The folder structure is However, another use of this feature is to be able to let applications and tests live side-by-side. You could #if !defined(MBED_TEST) || MBED_TEST == 0
int main() {
// Application code
}
#endif This would prevent the "multiple main" problem we currently have when building tests inside of an application |
Description
MBED_TEST macro can be used to guard test features or to select non-test related functionality (main) when building with
mbed compile
.Related : #7626
Pull request type
CC @theotherjimmy @bridadan