Skip to content
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

Remove unncecessary dependencies in tests #1114

Merged
merged 6 commits into from
Nov 16, 2023

Conversation

cwecht
Copy link
Contributor

@cwecht cwecht commented Oct 30, 2023

This PR removes AMENT_DEPENDENCIES to the respective RMW implementation in the RMW specific tests. I don't quite get why they have been there in the first place: having the RMW implementation mentioned as ament dependency should only result in linking against the RMW implementation, shouldn't it? For me this doesn't make sense, as the RMW implementation sould be loaded dynamically based on the RMW_IMPLEMENTATION environment variable.

With this PR the CMakeLists.txt gets quite a bit simple, too.

Copy link
Collaborator

@fujitatomoya fujitatomoya left a comment

Choose a reason for hiding this comment

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

i would like to have a couple of confirmation for this, for me it seems to be better to keep these.

CC: @clalancette @cottsay

rcl/test/CMakeLists.txt Show resolved Hide resolved
rcl/test/CMakeLists.txt Show resolved Hide resolved
@clalancette
Copy link
Contributor

I think we should do something like this, but it will have to be more in-depth.

In particular, we currently compile the same test multiple times, one for each RMW implementation we've found. But as you've noted, we don't actually need to do that; we just need to set RMW_IMPLEMENTATION appropriately.

So I think we should go further here and refactor this whole thing to only compile each of the tests once. There are some examples on how to do this in https://github.com/ros2/system_tests/blob/rolling/test_rclcpp/CMakeLists.txt . Not only will this improve our compilation times, it will also allow us to remove the last use of ament_target_dependencies from this package.

@cwecht are you willing to look at doing what I outlined above?

@cwecht cwecht force-pushed the remove_unncecessary_dependencies branch from 75c0738 to 308585c Compare October 31, 2023 11:37
@cwecht
Copy link
Contributor Author

cwecht commented Oct 31, 2023

@cwecht are you willing to look at doing what I outlined above?

Yes, done :)

@clalancette clalancette force-pushed the remove_unncecessary_dependencies branch from 308585c to ec44471 Compare November 10, 2023 01:10
Copy link
Contributor

@clalancette clalancette left a comment

Choose a reason for hiding this comment

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

@cwecht Thanks for getting this going.

First of all, with these changes I'm seeing my build times cut in half. So that is a great start.

Second, since we are removing the RMW_IMPLEMENTATION at build-time, we can also remove a whole slew of code inside the tests themselves that deal with all of that. I've pushed a commit which makes all of those changes (9c5363e).

Third, I found that some of the tests that were being run before weren't being run in this implementation. So I fixed that as well (ec44471).

Finally, the one real problem I have with this change is the rcl_add_custom_gtest_test. That is confusingly similar to the already existing rcl_add_custom_gtest. Also, it doesn't seem to be gtest-specific; it ends up calling ament_add_test, which doesn't really seem gtest-specific. And that cmake function has a lot of options that seem to be unused (I only see ENV and TIMEOUT being used anywhere). So I'd like to rethink that function a bit, either by using existing functionality, or by simplifying it and calling it something else. Thoughts?

@cwecht
Copy link
Contributor Author

cwecht commented Nov 10, 2023

@clalancette

Finally, the one real problem I have with this change is the rcl_add_custom_gtest_test. That is confusingly similar to the already existing rcl_add_custom_gtest. Also, it doesn't seem to be gtest-specific; it ends up calling ament_add_test, which doesn't really seem gtest-specific. And that cmake function has a lot of options that seem to be unused (I only see ENV and TIMEOUT being used anywhere). So I'd like to rethink that function a bit, either by using existing functionality, or by simplifying it and calling it something else. Thoughts?

rcl_add_custom_gtest_test is a copy of ament_add_gtest_test. With ament_add_gtest_test the name of the test and the executable must be the same. With rcl_add_custom_gtest_test the can diverge. With respect of its current usage scenario rcl_add_custom_gtest_test is a bit to complex, yes.

@clalancette
Copy link
Contributor

rcl_add_custom_gtest_test is a copy of ament_add_gtest_test. With ament_add_gtest_test the name of the test and the executable must be the same. With rcl_add_custom_gtest_test the can diverge. With respect of its current usage scenario rcl_add_custom_gtest_test is a bit to complex, yes.

OK, I see. Thanks for the context.

I think what I'd rather do here is to add a new optional argument (EXECUTABLE) to ament_add_gtest_test. Then we can just use ament_add_gtest_test here instead of basically duplicating it. Does that make sense?

If you are willing to do that, please open up a new PR to ament_cmake and I'm happy to review that one as well.

@cwecht
Copy link
Contributor Author

cwecht commented Nov 14, 2023

@clalancette I opted for adding a parameter TEST_NAME in ament/ament_cmake#492 instead of EXECUTABLE as seems to fit a bit better.

@clalancette
Copy link
Contributor

@cwecht Can you please add a Signed-off-by line to the latest commit? Once that is done, I think this is ready for CI. Thanks.

@cwecht cwecht force-pushed the remove_unncecessary_dependencies branch from ec6f9e4 to 5a832b7 Compare November 16, 2023 07:06
@cwecht
Copy link
Contributor Author

cwecht commented Nov 16, 2023

@clalancette done.

@cwecht Can you please add a Signed-off-by line to the latest commit? Once that is done, I think this is ready for CI. Thanks.

done.

@clalancette
Copy link
Contributor

Thanks. Here is CI:

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Windows Build Status

@cwecht
Copy link
Contributor Author

cwecht commented Nov 16, 2023

That last build failed because of an compilatin error in rclpy?

cwecht and others added 6 commits November 16, 2023 14:21
Signed-off-by: Christopher Wecht <cwecht@mailbox.org>
Signed-off-by: Christopher Wecht <cwecht@mailbox.org>
Signed-off-by: Christopher Wecht <cwecht@mailbox.org>
Since we are just using the environment variables to test
now, we don't need all of this superfluous infrastructure
for generating different RMW implementations.

Signed-off-by: Chris Lalancette <clalancette@gmail.com>
Signed-off-by: Chris Lalancette <clalancette@gmail.com>
@clalancette clalancette force-pushed the remove_unncecessary_dependencies branch from 5a832b7 to f3ac65f Compare November 16, 2023 14:21
@clalancette
Copy link
Contributor

That last build failed because of an compilatin error in rclpy?

Oh, right. This PR needs to be rebased due to the latest changes. I've gone ahead and done that.

@clalancette
Copy link
Contributor

New CI:

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Windows Build Status

@sloretz sloretz assigned sloretz and unassigned sloretz Nov 16, 2023
@clalancette clalancette merged commit cc0cd52 into ros2:rolling Nov 16, 2023
2 of 3 checks passed
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.

None yet

4 participants