-
Notifications
You must be signed in to change notification settings - Fork 3k
CMake: Refactor UNITTESTS CMake #14426
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
@rajkan01, thank you for your changes. |
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.
Herculean task (akin to cleaning up the Augean stables).
storage/kvstore/tdbstore/tests/UNITTESTS/TDBStore/CMakeLists.txt
Outdated
Show resolved
Hide resolved
Pull request has been modified.
sounds like it should be in "Impact of changes". @rajkan01 Please let us know once the fist comment is updated, we should review before merging - there could be lot of useful information our users need. |
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.
Thanks @rajkan01! Lots of good stuff here.
One slight concern from my standpoint: stubs and headers are defined "globally" across the OS, as opposed to the relevant component directory. The risk is that it becomes harder to maintain these components (as you have to change the stubs which are in a different place - which is not obvious, and there is duplication in terms of listing the relevant header files for instance).
Otherwise I see you've dropped the documentation, would be good to add something back except if I've missed something else.
Finally, more of a question - what's the impact (if any) on CLI1?
CMakeLists.txt
Outdated
if(${CMAKE_CROSSCOMPILING}) | ||
add_subdirectory(targets) | ||
# The directories below contain optional target libraries | ||
add_subdirectory(connectivity EXCLUDE_FROM_ALL) |
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.
Same, I understand why you're doing that but it's adding a bit of un-necessary complexity, as we should assume that most code we maintain will eventually have unit tests. Any reason why we can't remove EXCLUDE_FROM_ALL
in any case?
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.
Yes most of the components have unit test and we want to include to the build when we invoke unit test cmake command but in case of application build (Cross compiling), we would like to exclude to the build by default. When the application cmake target_link_libraries to any of the excluded component then it gets added into the build.
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.
I see why but this has implications beyond unit tests. I would suggest the specific unit testing targets are excluded from the all
target in the appropriate places, not at the top level here.
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.
If we remove EXCLUDE_FROM_ALL
then all the added CMake targets will be compiled when we try to build the CMake all
target (mbed-tools tries to build the all target as it has no knowledge of CMake target names). Using EXCLUDE_FROM_ALL
here allows us to specify which components of Mbed are built by using target_link_libraries in the consuming application. This isn't an ideal set-up but it was a pre-existing issue. I'd suggest we add an issue to the CMake milestone to tidy up here.
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.
I'd suggest we add an issue to the CMake milestone to tidy up here.
@rwalton-arm can you create an issue please for this?
@donatieng Thanks for your review comments No impact in Mbed CLI1 as mbed CLI 1 just directly calls the python modules in |
Back to review. Hopefully we can merge this once we release this week and unblock master. |
Pull request has been modified.
bf2ed7d
to
6d4caad
Compare
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.
Thanks for the additional comments and rework @rajkan01 and @rwalton-arm.
Let's get this in as it's a good starting point, but please raise issues for what needs to happen next :). Great work!
Thanks, Don for reviewing and approval this big PR |
CI restarted |
Jenkins CI Test : ✔️ SUCCESSBuild Number: 4 | 🔒 Jenkins CI Job | 🌐 Logs & ArtifactsCLICK for Detailed Summary
|
We will merge this once master is unblocked (release made) - it should be on Monday |
This PR does not contain release version label after merging. |
Summary of changes
mbed-stubs-connectivity
,mbed-stubs-drivers
,mbed-stubs-events
,mbed-stubs-hal
,mbed-stubs-platform
,mbed-stubs-rtos
,mbed-stubs-storage
so all libraries(drivers, platform etc.,) unittest CMakeLists.txt target link aginst to specifically required stub lib for their test or use mbed-stubs libraries which intern target linked to all stub librariesmbed-headers-base
,mbed-headers-platform
,mbed-headers-connectivity
,mbed-headers-storage
,mbed-headers-drivers
,mbed-headers-hal
,mbed-headers-events
,mbed-headers-rtos
so all libraries (drivers, platform etc.,) unit test CMakeLists.txt target link aginst to specifically required header interface lib or use mbed-headers libraries which intern target linked with all specific headers librariesImpact of changes
As part of this PR, we migrated to use the latest version CMake 3.19 or above version to build unit tests and the user must update their CMake to the latest version stated above
Migration actions required
Note:
Refer to official Mbed OS latest
debug-test/unit-testing
documentationExample section
which explains how to write a unittest forexample class
in a new wayDocumentation
ARMmbed/mbed-os-5-docs#1427
Pull request type
Test results
Reviewers
@hugueskamba @0xc0170 @evedon @LDong-Arm @pan- @paul-szczepanek-arm @jamesbeyond @rwalton-arm @Patater @donatieng