Skip to content

Deduplicate the shared_ptr and unique_ptr tests - #241

Merged
mjcarroll merged 2 commits into
rollingfrom
mjcarroll/dedupe-tests
Nov 9, 2026
Merged

mjcarroll merged 2 commits into
rollingfrom
mjcarroll/dedupe-tests

Conversation

@mjcarroll

Copy link
Copy Markdown
Member

Fixes #94.

utest.cpp and unique_ptr_test.cpp were near copies, differing only in createInstance() vs createUniqueInstance().

  • The managed-instance tests are now gtest typed tests that run with both, e.g. ClassLoaderTest/SharedPtr.basicLoad and ClassLoaderTest/UniquePtr.basicLoad. Tests that don't depend on the pointer type are in ClassLoaderBasicTest. unique_ptr_test.cpp is removed.
  • The unmanaged-instance tests move to their own executable (unmanaged_test.cpp). createUnmanagedInstance() disables on-demand unloading for the whole process, and the lazy-unload tests in utest.cpp only passed because gtest happened to run them first.
  • The try/catch + FAIL() wrappers are dropped, since gtest already reports uncaught exceptions as failures.

All existing assertions are kept. The test count goes from 36 to 35: one exact duplicate is removed (basicLoadFailures was in both files), and the MultiLibraryClassLoader missing-class test now runs for both pointer types instead of twice for unique_ptr.

Draft for now: #239 and #240 add tests to these files, so this will be rebased after they land.

utest.cpp and unique_ptr_test.cpp were copies of each other differing
only in createInstance() vs createUniqueInstance(). Make the managed
instance tests typed tests that run with both, and drop
unique_ptr_test.cpp.

The unmanaged instance tests move to their own executable:
createUnmanagedInstance() disables on-demand unloading for the whole
process, and utest.cpp's lazy-unload tests only passed because gtest
happened to run them first.

Fixes #94

Signed-off-by: Michael Carroll <mjcarroll.oss@gmail.com>
@mjcarroll
mjcarroll marked this pull request as ready for review November 5, 2026 19:26
@mjcarroll
mjcarroll force-pushed the mjcarroll/dedupe-tests branch from d1aa36d to e47b7c4 Compare November 5, 2026 19:26
@mjcarroll

Copy link
Copy Markdown
Member Author

Pulls: #241
Gist: https://gist.githubusercontent.com/mjcarroll/1dc1870b8d9d69faabdda3589aee1518/raw/b2bd8a7c2388bfcda9e7ec76d921c576160e91f7/ros2.repos
BUILD args: --packages-up-to class_loader
TEST args: --packages-select class_loader
ROS Distro: rolling
Job: ci_launcher
ci_launcher ran: https://ci.ros2.org/job/ci_launcher/21039

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

uncrustify 0.78.1 (uncrustify_vendor, Ubuntu) and 0.80.1 (EPEL, RHEL)
disagree on the spacing of '?' after 'is_same_v<...>', so no spelling of
the ternary passes both. Use if constexpr instead.

Signed-off-by: Michael Carroll <mjcarroll.oss@gmail.com>
@mjcarroll

Copy link
Copy Markdown
Member Author

Pulls: #241
Gist: https://gist.githubusercontent.com/mjcarroll/400d0f089e67322fb446b097e6b9c873/raw/b2bd8a7c2388bfcda9e7ec76d921c576160e91f7/ros2.repos
BUILD args: --packages-above-and-dependencies class_loader
TEST args: --packages-above class_loader
ROS Distro: rolling
Job: ci_launcher
ci_launcher ran: https://ci.ros2.org/job/ci_launcher/21042

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

@mjcarroll
mjcarroll merged commit 1bad36b into rolling Nov 9, 2026
4 checks passed
@mjcarroll
mjcarroll deleted the mjcarroll/dedupe-tests branch November 9, 2026 16:41
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.

Refactor tests to avoid code duplication

3 participants