Skip to content

Add docs about new test macro #1003

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

Conversation

bridadan
Copy link
Contributor

@bridadan bridadan commented Mar 8, 2019

This feature was added in Mbed CLI version 1.9.0 by @screamerbg. This adds documentation on how to use it.

@AnotherButler AnotherButler requested a review from screamerbg March 8, 2019 16:32
Copy link
Contributor

@AnotherButler AnotherButler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR 👍

Copy link

@screamerbg screamerbg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this. See comment.

The macro `MBED_TEST_MODE` is defined when building tests with Mbed CLI versions 1.9.0 and later. You can wrap your application's `main()` function in a preprocessor check to prevent multiple `main()` functions from being defined:

```c++
#if !MBED_TEST_MODE

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency shall this be #ifndef MBED_TEST_MODE? See https://github.com/ARMmbed/pelion-ready-example/blob/master/main.cpp

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went with #if !MBED_TEST_MODE so you could also set MBED_TEST_MODE=0 for testing purposes. Specifying it as #ifndef would always evaluate to false, even if the macro was set to 0. A similar pattern is used within Mbed OS: ARMmbed/mbed-os#8957

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants