Skip to content

ENH: Convert 18 Modules/Core/Common tests from CTest to GoogleTest#6246

Open
hjmjohnson wants to merge 1 commit intoInsightSoftwareConsortium:mainfrom
hjmjohnson:convert-common-gtests-fresh-2026-05-09
Open

ENH: Convert 18 Modules/Core/Common tests from CTest to GoogleTest#6246
hjmjohnson wants to merge 1 commit intoInsightSoftwareConsortium:mainfrom
hjmjohnson:convert-common-gtests-fresh-2026-05-09

Conversation

@hjmjohnson
Copy link
Copy Markdown
Member

@hjmjohnson hjmjohnson commented May 9, 2026

Mechanical CTest → GoogleTest conversion of 18 no-argument tests in
Modules/Core/Common/test. Each file uses git mv + minimal-diff
wrap-and-call so git log --follow walks through the rename.

Conversion pattern

The original int itkFooTest(int, char *[]) body is preserved
verbatim — every comment, blank line, and std::cout line — wrapped
in an anonymous namespace as DoFooTest, and invoked from a single
TEST(Foo, ConvertedLegacyTest) block. The only edits are:

  1. Add #include "itkGTest.h" after the primary include.
  2. namespace { int Foo(...) → namespace { int DoFoo(...).
  3. Append } // namespace + TEST(Suite, ConvertedLegacyTest) { EXPECT_EQ(0, DoFoo(0, nullptr)); }.

No logic, no assertion conversion, no comment edits. Each rename
pair stays well above git's 50% similarity threshold (91-97%).

Tests converted (alphabetical)
  • itkBSplineInterpolationWeightFunctionTest
  • itkConicShellInteriorExteriorSpatialFunctionTest
  • itkEllipsoidInteriorExteriorSpatialFunctionTest
  • itkFileOutputWindowTest
  • itkFiniteCylinderSpatialFunctionTest
  • itkFrustumSpatialFunctionTest
  • itkRealTimeClockTest
  • itkSTLContainerAdaptorTest
  • itkSimpleFilterWatcherTest
  • itkSparseFieldLayerTest
  • itkSparseImageTest
  • itkSpatialFunctionTest
  • itkSpatialOrientationTest
  • itkSymmetricEllipsoidInteriorExteriorSpatialFunctionTest
  • itkTorusInteriorExteriorSpatialFunctionTest
  • itkVariableSizeMatrixTest
  • itkVNLSparseLUSolverTraitsTest
  • itkZeroFluxBoundaryConditionTest

Modules/Core/Common/test/CMakeLists.txt: legacy entries removed
from ITKCommon{1,2}Tests + their itk_add_test blocks dropped;
new *GTest.cxx entries inserted alphabetically into
ITKCommonGTests.

Local verification
  • pre-commit run --all-files clean
  • ITKCommonGTestDriver builds
  • ./bin/ITKCommonGTestDriver --gtest_filter='*ConvertedLegacyTest*' → 39/39 passed (some files contain multiple TEST blocks)

@github-actions github-actions Bot added type:Infrastructure Infrastructure/ecosystem related changes, such as CMake or buildbots type:Enhancement Improvement of existing methods or implementation type:Testing Ensure that the purpose of a class is met/the results on a wide set of test cases are correct area:Core Issues affecting the Core module labels May 9, 2026
@hjmjohnson
Copy link
Copy Markdown
Member Author

@greptile review

@greptile-apps

This comment was marked as resolved.

Mechanical CTest -> GTest conversion of 18 no-argument tests in
Modules/Core/Common/test, using git mv + minimal-diff wrap-and-call:
the original itkFooTest(int, char*[]) function body is preserved
verbatim (including comments, std::cout output, and blank-line
layout), wrapped in an anonymous namespace as DoFooTest, and invoked
from a single TEST(Foo, ConvertedLegacyTest) block. #include
"itkGTest.h" is added; no other content edits. Each renamed file is
above git's 50% similarity threshold so git log --follow tracks
through the conversion.

Converted (alphabetical):
  itkBSplineInterpolationWeightFunctionTest
  itkConicShellInteriorExteriorSpatialFunctionTest
  itkEllipsoidInteriorExteriorSpatialFunctionTest
  itkFileOutputWindowTest
  itkFiniteCylinderSpatialFunctionTest
  itkFrustumSpatialFunctionTest
  itkRealTimeClockTest
  itkSTLContainerAdaptorTest
  itkSimpleFilterWatcherTest
  itkSparseFieldLayerTest
  itkSparseImageTest
  itkSpatialFunctionTest
  itkSpatialOrientationTest
  itkSymmetricEllipsoidInteriorExteriorSpatialFunctionTest
  itkTorusInteriorExteriorSpatialFunctionTest
  itkVariableSizeMatrixTest
  itkVNLSparseLUSolverTraitsTest
  itkZeroFluxBoundaryConditionTest

CMakeLists.txt updated: legacy entries removed from ITKCommon{1,2}Tests
and itk_add_test blocks dropped; new *GTest.cxx entries inserted
alphabetically into ITKCommonGTests.
@hjmjohnson hjmjohnson changed the title ENH: Convert 17 Modules/Core/Common tests from CTest to GoogleTest ENH: Convert 18 Modules/Core/Common tests from CTest to GoogleTest May 9, 2026
@hjmjohnson hjmjohnson force-pushed the convert-common-gtests-fresh-2026-05-09 branch from 2630715 to 1f866e7 Compare May 9, 2026 14:50
@hjmjohnson
Copy link
Copy Markdown
Member Author

Fixed in 1f866e7 — corrected count from 17 to 18 in commit subject, PR title, and PR body. Greptile P2 finding addressed.

@hjmjohnson hjmjohnson marked this pull request as ready for review May 9, 2026 14:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:Core Issues affecting the Core module type:Enhancement Improvement of existing methods or implementation type:Infrastructure Infrastructure/ecosystem related changes, such as CMake or buildbots type:Testing Ensure that the purpose of a class is met/the results on a wide set of test cases are correct

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant