rcl icon indicating copy to clipboard operation
rcl copied to clipboard

Add option to skip mimick based tests

Open ivanpauno opened this issue 3 years ago • 7 comments

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.

ivanpauno avatar Jul 06 '21 19:07 ivanpauno

My idea is to add an ament_add_mimick_test() macro in ament_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.).

hidmic avatar Jul 07 '21 14:07 hidmic

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 (?).

ivanpauno avatar Jul 07 '21 14:07 ivanpauno

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.

ivanpauno avatar Jul 07 '21 14:07 ivanpauno

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()

hidmic avatar Jul 07 '21 18:07 hidmic

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.

ivanpauno avatar Jul 07 '21 19:07 ivanpauno

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.

hidmic avatar Jul 07 '21 20:07 hidmic

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.

ivanpauno avatar Jul 09 '21 16:07 ivanpauno

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.

clalancette avatar Jul 26 '24 19:07 clalancette