-
Notifications
You must be signed in to change notification settings - Fork 431
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
Add in tests for the static executor #1331
Conversation
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.
Most of my comments are just due to some formatting that seems a bit different then I've seen elsewhere in rclcpp
. Also, I'm curious whether this makes sense as several PRs rather than just one larger one.
rclcpp/include/rclcpp/executors/static_executor_entities_collector.hpp
Outdated
Show resolved
Hide resolved
rclcpp/src/rclcpp/executors/static_executor_entities_collector.cpp
Outdated
Show resolved
Hide resolved
|
||
TEST_F(TestStaticExecutorEntitiesCollector, add_callback_group) { | ||
auto node = std::make_shared<rclcpp::Node>("node1", "ns"); | ||
rclcpp::CallbackGroup::SharedPtr cb_group = node->create_callback_group( |
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.
A bit of a nitpick here, but I think using auto
would let you put these two lines onto one, which would help readability a small bit with all these new tests. Likewise, I would recommend to avoid abbreviations like 'cb_group' if possible (either group
or callback_group
). Fix here and below
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.
Would that actually work, though? If I do that, then the node pointer becomes a temporary, and then wouldn't it be destroyed immediately after this line (since there are no more handles to it)?
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.
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.
Disagreements about the awesomeness and power of auto in a unit test aside, I'm fine leaving these as is.
rclcpp/test/rclcpp/executors/test_static_executor_entities_collector.cpp
Show resolved
Hide resolved
auto subscription = | ||
node->create_subscription<test_msgs::msg::Empty>( | ||
"topic", rclcpp::QoS(10), [](test_msgs::msg::Empty::SharedPtr) {}); | ||
auto timer = |
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.
Nit: was this line break intentional?
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 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.
Not sure about this one. uncrustify definitely told me to make this change, though you are right that it can probably be collapsed to one line.
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.
Strange, uncrustify is happy with this on my machine,
auto timer = node->create_wall_timer(std::chrono::seconds(60), []() {});
rclcpp/test/rclcpp/executors/test_static_executor_entities_collector.cpp
Outdated
Show resolved
Hide resolved
rclcpp/test/rclcpp/executors/test_static_single_threaded_executor.cpp
Outdated
Show resolved
Hide resolved
rclcpp/test/rclcpp/executors/test_static_single_threaded_executor.cpp
Outdated
Show resolved
Hide resolved
I honestly just write code in my own style, and then do what uncrustify tells me to make it pass the linters. It is often the case that several things would satisfy uncrustify, but I just always take the one it tells me to do.
Yeah, I debated about that. I decided to put it into a single PR for a few reasons:
If you'd still like me to split it up, how many more PRs would you suggest? I can see arguments for 1, 2, 3, 4, or 5 :). |
83c1414
to
cc6ffde
Compare
I waffled myself on how many would make sense. I think separating out the API changes would be good and then you can tag some reviewers that might have more insight into the intended use of these classes than myself. Otherwise, it's just a matter of backportability. When adding coverage our general guiding principle has been that bugs should be back portable to whatever ros distro's make sense and tests should be backportable to foxy. However, I was under the impression you were adding coverage for stuff mostly added only in rolling, so separating out into more PRs might not provide much benefit. |
Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>
We need to determine if this is a new node *before* adding it to the list; otherwise, it will always be treated as an old node. Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>
Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>
We get to 97% code coverage with these tests in place. Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>
Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>
cc6ffde
to
bb4cb74
Compare
All right, I've rebased and left only the changes that don't affect API here. I'll open a separate PR for the API changes presently. I'm going to mark this as an in-progress PR now, and run another round of CI here. |
auto subscription = | ||
node->create_subscription<test_msgs::msg::Empty>( | ||
"topic", rclcpp::QoS(10), [](test_msgs::msg::Empty::SharedPtr) {}); | ||
auto timer = |
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.
Strange, uncrustify is happy with this on my machine,
auto timer = node->create_wall_timer(std::chrono::seconds(60), []() {});
|
||
TEST_F(TestStaticExecutorEntitiesCollector, add_callback_group) { | ||
auto node = std::make_shared<rclcpp::Node>("node1", "ns"); | ||
rclcpp::CallbackGroup::SharedPtr cb_group = node->create_callback_group( |
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.
Disagreements about the awesomeness and power of auto in a unit test aside, I'm fine leaving these as is.
Thanks for the reviews! |
This PR adds in tests for the
StaticSingleThreadedExecutor
and a helper class,StaticExecutorEntitiesCollector
. With this PR in place, I see 97% line coverage on static_single_threaded_executor.cpp and 97% line coverage on static_executor_entities_collector.cpp.Along the way, I found a few bugs and other problems that I've fixed:
const
to variables to give the compiler a bit more of a hint.Note that this is still in draft because I want to run CI on it (particularly for Windows). I'll pull it out of draft once CI comes back clean.