rcl
rcl copied to clipboard
Add option to skip mimick based tests
Mimick is a really platform dependent library. e.g. Android has its own ABI for arm, so the library doesn't compile there.
That makes imposible to crosscompile ROS 2 to android, which is something that rcljava was testing.
Depends on https://github.com/ros2/mimick_vendor/pull/21.
My idea is to add an
ament_add_mimick_test()
macro inament_cmake
instead of here.
Hmm, Mimick is rarely used alone. Most tests are GTests that use Mimick. So perhaps a macro that just adds the dependency (and related properties) would avoid combinatorial expansion (if no GTest is used, if GMock is used, if Catch2 is used, etc.).
Hmm, Mimick is rarely used alone. Most tests are GTests that use Mimick. So perhaps a macro that just adds the dependency (and related properties) would avoid combinatorial expansion (if no GTest is used, if GMock is used, if Catch2 is used, etc.).
Yeah, I also thought about gtest vs gmock. What you propose works if the test will add mimick as a target link library when AMENT_IGNORE_MIMICK_TESTS=ON and define a precompiler variable when not.
That doesn't cover the case of skipping the test though, as that is an argument of ament_add_test().
I don't think there's going to be combinatorial expansion in practice, most likely we're always going to use mimick combined with gtest or gmock. Maybe we can add a ament_add_mimick_test()
that uses gtest by default but has a GMOCK argument (?).
That doesn't cover the case of skipping the test though, as that is an argument of ament_add_test().
We are going to rarely skip a complete test file though, e.g. this PR doesn't use that.
So maybe we can just go with a macro that's used after ament_add_gtest()/ament_add_gmock()
as you suggested.
We are going to rarely skip a complete test file though, e.g. this PR doesn't use that. So maybe we can just go with a macro that's used after ament_add_gtest()/ament_add_gmock() as you suggested.
Yeah, but you have a point. It's not enough to skip whole tests. How about adding both a preprocessor variable and a global CMake variable? We can skip whole tests by conditioning them on that variable e.g.:
if (NOT SKIP_MIMICK)
ament_add_gtest(some_test ...)
target_link_libraries(some_test mimick_vendor) # to bring includes, libraries, and preprocessor variables
endif()
SKIP_MIMICK
what sets the value of the global CMake variable? or is that one passed by the user directly?
If the second one is the case, we would need to add an option(SKIP_MIMICK ...)
in all cmakelists where we use this.
what sets the value of the global CMake variable?
I think much of machinery (to set a variable, to add an option, etc.) could live in mimick_vendor
. Specifically in an extra configuration .cmake
file.
I think much of machinery (to set a variable, to add an option, etc.) could live in
mimick_vendor
. Specifically in an extra configuration.cmake
file.
Done, this PR depends on https://github.com/ros2/mimick_vendor/pull/21 now.
We actually came up with a different way to do this, which is to label all of the tests using Mimick with the mimick
label. Then you can just ask ctest to skip those with the -LE mimick
flag.
Given that, and the age of this, I'm going to go ahead and close this one out.