Skip to content

test: add unit tests for create_callback_group_id#58

Merged
atsushi421 merged 3 commits into
autowarefoundation:mainfrom
ran2810:test/cie-thread-configurator-utils-test
Jun 24, 2026
Merged

test: add unit tests for create_callback_group_id#58
atsushi421 merged 3 commits into
autowarefoundation:mainfrom
ran2810:test/cie-thread-configurator-utils-test

Conversation

@ran2810

@ran2810 ran2810 commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Description

Adds unit tests for create_callback_group_id (cie_thread_configurator/src/util.cpp), addressing the first unit-test item in #38.

Covers:

  • Root namespace produces a single leading slash (/node, not //node)
  • Non-root namespace path (/ns/node)
  • The trailing @ separator is stripped from the result
  • Timer entities are identified by period in nanoseconds
  • The Node overload matches the NodeBaseInterface overload

Tests use ament_add_ros_isolated_gtest so each case runs in an isolated ROS context.

Related links

Part of #38

How was this PR tested?

Built and ran locally on ROS 2 Humble:

  • colcon test --packages-select cie_thread_configurator — all 5 gtest cases pass
  • pre-commit run --files ... passes (clang-format clean)

Note: the gtest target is not picked up by the current CI test step, which filters to -L launch_test. Wiring CI to run gtest unit tests is itself an open item in #38 and is out of scope for this PR.

Notes for reviewers

  • Scope is limited to create_callback_group_id unit tests only, per the suggested starting point in test: add unit and integration tests #38.
  • The pre-existing ament linter failures (copyright/cpplint/uncrustify) on other files in the package are unrelated to this change and not addressed here.

Signed-off-by: ran2810 <prkr@mail.de>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds isolated ROS 2 unit tests for cie_thread_configurator::create_callback_group_id, improving regression coverage for callback-group ID formatting behavior described in #38.

Changes:

  • Add ament_add_ros_isolated_gtest-based gtests covering namespace formatting, trailing separator stripping, timer period encoding, and overload consistency.
  • Extend cie_thread_configurator test dependencies to include ament_cmake_ros and std_msgs.
  • Register the new test_util target in cie_thread_configurator/CMakeLists.txt.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
cie_thread_configurator/test/test_util.cpp Adds isolated gtests validating create_callback_group_id string formatting across several entity/namespace cases.
cie_thread_configurator/package.xml Adds test dependencies needed by the new isolated gtest and message type used in the test.
cie_thread_configurator/CMakeLists.txt Adds isolated gtest target and test-only package discovery (but currently needs target-order fix).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread cie_thread_configurator/CMakeLists.txt Outdated

@atsushi421 atsushi421 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The tests cover only Subscription and Timer, but create_callback_group_id also handles Service, Client, and Waitable entities and joins multiple entities with '@'. The multi-entity case (the internal '@' join and the collect_all_ptrs ordering) is never exercised, and the trailing-'@' test only proves single-entity suffix removal. Consider adding tests for a Service, a Client, and a group with 2+ entities that asserts the joined ordering.

Comment thread cie_thread_configurator/test/test_util.cpp Outdated
Comment thread cie_thread_configurator/CMakeLists.txt Outdated
@atsushi421

Copy link
Copy Markdown
Collaborator

Thank you for your contribution! Could you address the comments above and use the AAA pattern for unit tests?

@ran2810

ran2810 commented Jun 24, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the thorough review @atsushi421! Addressed all comments:

Added Service, Client, and a multi-entity test asserting the full @-joined string. The multi-entity test pins the actual collect_all_ptrs emission order, which turned out to be subscription → service → client → timer.
Replaced the trailing-@ test with an empty-group case asserting the result equals exactly /test_node, so it exercises the stripping path directly.
Removed the redundant cie_config_msgs from ament_target_dependencies.
Restructured all tests using the AAA pattern.

All 8 tests pass locally and pre-commit is clean. Ready for another look.

@atsushi421 atsushi421 enabled auto-merge June 24, 2026 21:11
@atsushi421 atsushi421 merged commit c5bf54a into autowarefoundation:main Jun 24, 2026
5 checks passed
@atsushi421 atsushi421 self-requested a review June 24, 2026 21:25
@atsushi421

Copy link
Copy Markdown
Collaborator

@ran2810
LGTM! Merged!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants