Closed maxpeng closed 5 years ago
@maxpeng That's a good work around!
You can do the build run step separately:
mbed test -m xxx -t xxx -DUNIT_TEST --compile
mbed test -m xxx -t xxx --run
@bridadan Thanks for your tip - split the intended action into 2 steps.
I wonder if it is better for the mbed test
command to automatically define some kind of macro to ease the task.
@bridadan @maxpeng Is there any follow up on this? If not, are you happy to close this issue?
I wonder if it is better for the mbed test command to automatically define some kind of macro to ease the task.
That seems reasonable honestly, and I bet a lot of folks would appreciate that.
@theotherjimmy how do you feel about that?
Sounds like a workable plan to me.
I face similar issue, trying to build application (using mbed compile
) and tests (using mbed test
) under the same working tree.
Please consider another way for the fix, by ignoring main
functions outside of TESTS directories when building tests using mbed test
.
In that way there is no need to use another compilation flag.
@screamerbg Fix of this issue will help us for compilation of our unit tests. I believe that also @TeroJaasko will find this useful (for compiling PAL unit tests from Pelion Client application). Is this something that can be considered to be added in next mbed-cli version?
@jenia81 The Mbed CLI version has no bearing on the behavior of mbed test --compile
, outside of accepting the --icetea
and --greentea
switches.
@moshe-shahar
by ignoring main functions outside of TESTS directories when building tests using mbed test.
I'm sure this would be useful, but how do you propose we do that? As it stands, the build tools don't know where main
lives, and only deal with source files.
@theotherjimmy ,I understand. Thanks for your answer.
Internal Jira reference: https://jira.arm.com/browse/MBOCUSTRIA-72
@moshe-shahar 5 months have gone by, and it appears that Jimmy answered your question by explaining the limitations of what can be determined by the CLI when a program is being compiled. This issue will now be closed if there are no further questions.
Ok, thanks!
From: Tres Hill notifications@github.com Sent: Monday, March 11, 2019 4:37 PM To: ARMmbed/mbed-cli mbed-cli@noreply.github.com Cc: Moshe Shahar Moshe.Shahar@arm.com; Mention mention@noreply.github.com Subject: Re: [ARMmbed/mbed-cli] Run test for the case that application contains a main function (#537)
@moshe-shaharhttps://github.com/moshe-shahar 5 months have gone by, and it appears that Jimmy answered your question by explaining the limitations of what can be determined by the CLI when a program is being compiled. This issue will now be closed if there are no further questions.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/ARMmbed/mbed-cli/issues/537#issuecomment-471564759, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AeH3gb9EMUilYpOcOHQIYrnOZbRz7xHwks5vVmoGgaJpZM4PC6RG.
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
Note that as of version 1.9.0 of Mbed CLI, we add the MBED_TEST_MODE
macro when compiling with mbed test
. Here are the docs describing the feature: https://github.com/ARMmbed/mbed-os-5-docs/pull/1003
From the mbed CLI documentation, it describes this:
For normal project layout, we will place a main function outside the TESTS directory, and place unit test code inside TESTS directory. I didn't want to rename the file containing main, so I tried to write the application C file containing main function as:
That is, when UNIT_TEST is defined, the application main will not be included. Then I tried to build the test code by this command:
Although the documentation does not describe it support
-D
option, the test code could be compiled successfully. Unfortunately, thembedgt
didn't like the-D
option:How do we build the application and test code easily by using mbed CLI?