Skip to content

Fix NodeOptions assignment operator#2656

Merged
clalancette merged 3 commits intoros2:rollingfrom
rdesille:rolling
Oct 30, 2024
Merged

Fix NodeOptions assignment operator#2656
clalancette merged 3 commits intoros2:rollingfrom
rdesille:rolling

Conversation

@rdesille
Copy link
Copy Markdown
Contributor

While working with NodeOptions, I realized "enable_logger_service" was copied with the assignment operator.
Here is a little PR to fix the issue. I also added some additional checks for primitives members in TEST(TestNodeOptions, copy).

Let me know what you think

Also copy the enable_logger_service_ member during the assignment operation

Signed-off-by: Romain DESILLE <r.desille@gmail.com>
EXPECT_EQ(options.use_clock_thread(), copied_options.use_clock_thread());
EXPECT_EQ(options.allow_undeclared_parameters(), copied_options.allow_undeclared_parameters());
EXPECT_EQ(options.automatically_declare_parameters_from_overrides(), copied_options.automatically_declare_parameters_from_overrides());

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

can you check all attributes here?

Also, this test isn't testing much, because enable_logger_service_ is false by default and the test does not change its value before copy-assigning it. In other words, this test passes even without your fix.

I'd say move this part to the end of this test, create a NodeOptions object, try to set all options to the non-default value, then copy-assign it to a second object, and then assert equality of each attribute.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

You're right, I realized the current test was not tested anything after I submitted the PR.
Thanks for the hint, I will modify the test.

@christophebedard
Copy link
Copy Markdown
Member

Nice catch! Looks like this was missed in #2122. I just have one simple comment.

Then we should backport this to Jazzy and Iron.

Signed-off-by: Romain DESILLE <r.desille@gmail.com>
@rdesille
Copy link
Copy Markdown
Contributor Author

rdesille commented Oct 28, 2024

I added more tests and a small comment to list attributes that were not / couldn't be tested.
Formatting should also be fixed. Let me know what you think.

How does backports to Jazzy and Iron works? Should I open PR to the said branches after this one is approved?
Sorry I am new to ROS contributions. 👼

@alsora
Copy link
Copy Markdown
Collaborator

alsora commented Oct 28, 2024

@rdesille thank you for your contribution!

How does backports to Jazzy and Iron works? Should I open PR to the said branches after this one is approved?
Sorry I am new to ROS contributions

We should first finish to review and merge this PR.
Then we can try to automatically backport it.

CI run:

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

Copy link
Copy Markdown
Member

@christophebedard christophebedard left a comment

Choose a reason for hiding this comment

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

Last tiny change!

Co-authored-by: Christophe Bedard <bedard.christophe@gmail.com>
Signed-off-by: Romain DESILLE <r.desille@gmail.com>
Copy link
Copy Markdown
Member

@christophebedard christophebedard left a comment

Choose a reason for hiding this comment

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

Thanks for making the changes!

@christophebedard
Copy link
Copy Markdown
Member

christophebedard commented Oct 29, 2024

Pulls: #2656
Gist: https://gist.githubusercontent.com/christophebedard/1de00d2d06f7b1dc7112ca903630b017/raw/30532634394c0b20a75069ce01597657f2b928eb/ros2.repos
BUILD args: --packages-above-and-dependencies rclcpp
TEST args: --packages-above rclcpp
ROS Distro: rolling
Job: ci_launcher
ci_launcher ran: https://ci.ros2.org/job/ci_launcher/14752

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

@clalancette clalancette merged commit 9b65494 into ros2:rolling Oct 30, 2024
@fujitatomoya
Copy link
Copy Markdown
Collaborator

@Mergifyio backport jazzy

@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Oct 30, 2024

backport jazzy

✅ Backports have been created

Details

@fujitatomoya
Copy link
Copy Markdown
Collaborator

i will backport this only to jazzy. (Iron is just one day away from E.O.L and humble does not have this code.)

mergify bot pushed a commit that referenced this pull request Oct 30, 2024
* Fix NodeOptions assignment operator

Also copy the enable_logger_service_ member during the assignment operation

* Add more checks for NodeOptions copy test

* Set non default values by avoiding the copy-assignement

Signed-off-by: Romain DESILLE <r.desille@gmail.com>
Co-authored-by: Christophe Bedard <bedard.christophe@gmail.com>
(cherry picked from commit 9b65494)
christophebedard pushed a commit that referenced this pull request Nov 7, 2024
* Fix NodeOptions assignment operator

Also copy the enable_logger_service_ member during the assignment operation

* Add more checks for NodeOptions copy test

* Set non default values by avoiding the copy-assignement

Signed-off-by: Romain DESILLE <r.desille@gmail.com>
Co-authored-by: Christophe Bedard <bedard.christophe@gmail.com>
(cherry picked from commit 9b65494)

Co-authored-by: Romain DESILLE <r.desille@gmail.com>
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.

5 participants