Skip to content

Move all gtests out of MRMesh into MRTest; drop MRMesh's GTest dependency#6171

Merged
Fedr merged 8 commits into
masterfrom
move-mrmesh-gtests-to-mrtest
May 27, 2026
Merged

Move all gtests out of MRMesh into MRTest; drop MRMesh's GTest dependency#6171
Fedr merged 8 commits into
masterfrom
move-mrmesh-gtests-to-mrtest

Conversation

@Fedr
Copy link
Copy Markdown
Contributor

@Fedr Fedr commented May 27, 2026

Summary

Removes all GoogleTest code from the MRMesh library and consolidates it in the MRTest project. After this PR, MRMesh contains no TEST(...) cases, no test-only headers, and no dependency on GTest.

Continues the ongoing effort started in #6132 (MeshBoolean) and #6145 (FixSelfIntersections).

Tests moved out of MRMesh

All remaining TEST(MRMesh, …) cases (plus a few other suites such as TEST(MRFinally, …)) move from source/MRMesh/ into source/MRTest/:

  • 39 mixed files (production code + tests): test blocks are extracted into a new source/MRTest/<Name>Tests.cpp, wrapped in namespace MR, with <MRMesh/…> angle-bracket includes; test-only includes are dropped from the source.
  • 2 test-only files moved wholesale via git mv (history preserved): MRMeshBuildDeleteTest.cpp, MRDistanceMapTests.cpp.
  • TEST(MRMesh, SurfaceDistance)MRSurfaceDistanceBuilderTests.cpp, enabled by exporting getFieldAtC (MRMESH_API) so the test can reach it across the shared-library boundary.

Template-instantiation compile-checks moved out

The // verifies that template can be instantiated with typical parameters explicit instantiations move into MRTest (they carry no MRMESH_API, so nothing links against them; the check is now done by the MRTest build):

  • AffineXf<Vector2<…>> / AffineXf<Vector3<…>>MRAffineXf2Tests.cpp / MRAffineXf3Tests.cpp
  • BestFitParabola<float|double>MRBestFitParabolaTests.cpp
  • QuadraticForm<Vector2|3<…>> → new MRQuadraticFormTests.cpp (MRQuadraticForm.cpp keeps its MRMESH_API sum/sumAt instantiations — those are genuine exported symbols)

MRGTest.h removed

MRGTest.h (a gtest wrapper that stubbed the macros when GTest was unavailable) is no longer needed now that all tests live in MRTest, which always links GTest. source/MRMesh/MRGTest.h is deleted and every usage is replaced with <gtest/gtest.h>. The stale MRGTest.h includes are also dropped from the four MRMesh files that no longer used it (MRAABBTreePolyline, MRBestFit, MRBitSet, MRCylinderObject).

Cleanup

  • Empty MRMesh .cpp files left after the moves are removed: MRAABBTreePolyline2, MRAABBTreePolyline3, MRAffineXf2, MRAffineXf3, MRBestFitParabola, MRFinally, MRId, MRIntersection, MRLine3, MRTupleBindings, MRViewportId.
  • The now-dead find_package(GTest) + GTest::gtest link is removed from MRMesh/CMakeLists.txt, and the find_dependency(GTest) block from MRMeshConfig.cmake.in.
  • MRMesh.vcxproj / .filters and MRTest.vcxproj / .filters updated accordingly. CMake discovers sources via file(GLOB …).

Notes / non-obvious bits

  • Two file-local helpers were duplicated (with internal linkage) into the new test files because production code still uses the originals: getNormalizedRadiusByAngle / cBaseHeightMRConeObjectTests.cpp, and triangleSolidAngleMRDipoleTests.cpp.
  • The MRMESH_NO_GTEST option is kept in MRMesh/CMakeLists.txt: the CMake variable still gates GTest precompiled-header reuse in MRPch/CMakeLists.txt.

Test plan

  • CI: MRTest builds and runs all relocated cases on every platform (incl. Emscripten and the MSVC .vcxproj build)
  • MRMesh builds with no gtest cases, no MRGTest.h, and no GTest dependency

Fedr and others added 6 commits May 27, 2026 13:31
Relocate 71 of the remaining 72 TEST(MRMesh, ...) cases from 41 files in
source/MRMesh into source/MRTest, continuing the work of #6132 and #6145.

- 39 mixed files: tests extracted into source/MRTest/<Name>Tests.cpp,
  wrapped in namespace MR with <MRMesh/...> includes; MRGTest.h and other
  test-only includes dropped from the sources.
- 2 test-only files moved wholesale (git mv) and removed from
  MRMesh.vcxproj/.filters: MRMeshBuildDeleteTest.cpp, MRDistanceMapTests.cpp.
- MRTest.vcxproj/.filters updated; CMake auto-discovers new files via GLOB.

TEST(MRMesh, SurfaceDistance) stays in MRMesh: it calls the file-static
helper getFieldAtC (shared with production code), which is not exported
from the shared MRMesh library, so moving it would require an API change.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…rces

Relocate the "// verifies that template can be instantiated with typical
parameters" explicit instantiations into the MRTest project:
- AffineXf<Vector2<...>> / AffineXf<Vector3<...>> into MRAffineXf2Tests.cpp
  and MRAffineXf3Tests.cpp
- BestFitParabola<float|double> into MRBestFitParabolaTests.cpp
- QuadraticForm<Vector2|3<...>> into a new MRQuadraticFormTests.cpp
  (MRQuadraticForm.cpp keeps its MRMESH_API sum/sumAt instantiations,
  which are real exported symbols).

These instantiations are header-only compile checks (no MRMESH_API), so
nothing links against them; the check is now performed by the MRTest build.

Remove the MRMesh .cpp files left with no code after the test and
instantiation moves, and drop their MRMesh.vcxproj/.filters entries:
MRAABBTreePolyline2, MRAABBTreePolyline3, MRAffineXf2, MRAffineXf3,
MRBestFitParabola, MRFinally, MRId, MRIntersection, MRLine3,
MRTupleBindings, MRViewportId.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Now that getFieldAtC is exported (MRMESH_API), the last remaining gtest in
MRMesh moves into source/MRTest/MRSurfaceDistanceBuilderTests.cpp. Drop the
test and the now-unused MRGTest.h include from MRSurfaceDistanceBuilder.cpp.

MRMesh no longer contains any gtest cases.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
MRGTest.h is a gtest wrapper used only by tests, which now all live in
MRTest. Move source/MRMesh/MRGTest.h to source/MRTest/MRGTest.h and switch
its "config.h" include to <MRMesh/config.h> so it resolves from the new
location.

Update every MRTest .cpp to include the header locally ("MRGTest.h" instead
of <MRMesh/MRGTest.h>), and drop the now-stale MRGTest.h includes from the
MRMesh files that no longer use it (MRAABBTreePolyline, MRBestFit, MRBitSet,
MRCylinderObject). Remove its MRMesh.vcxproj/.filters entries.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- Add MRGTest.h as a ClInclude to MRTest.vcxproj and MRTest.vcxproj.filters
  (the move in the previous commit updated only the MRMesh project files).
- Remove the now-dead `find_package(GTest)` + `GTest::gtest` link from
  MRMesh/CMakeLists.txt, since MRMesh no longer contains any gtest code.

The MRMESH_NO_GTEST option is kept: it still feeds config_cmake.h.in (the
macro read by MRGTest.h), MRMeshConfig.cmake.in, and MRPch/CMakeLists.txt.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@Fedr Fedr changed the title Move MRMesh gtests to MRTest project Move all gtests and MRGTest.h out of MRMesh into MRTest May 27, 2026
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.

Consider removing find_dependency(GTest) from MRMeshConfig.cmake.in as well.

Comment thread source/MRTest/MRGTest.h Outdated
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.

This header is not required anymore, remove it and replace all its usages with <gtest/gtest.h>.

Comment thread source/MRTest/MRQuadraticFormTests.cpp
Per review feedback:
- MRGTest.h is no longer needed now that all gtests live in MRTest (which
  always links GTest). Remove source/MRTest/MRGTest.h and replace every
  usage with <gtest/gtest.h>; drop its MRTest.vcxproj/.filters entry.
- Remove the now-stale find_dependency(GTest) block from
  MRMeshConfig.cmake.in (MRMesh no longer depends on GTest).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@Fedr Fedr changed the title Move all gtests and MRGTest.h out of MRMesh into MRTest Move all gtests out of MRMesh into MRTest; drop MRMesh's GTest dependency May 27, 2026
@Fedr Fedr merged commit 0f5ad6b into master May 27, 2026
39 checks passed
@Fedr Fedr deleted the move-mrmesh-gtests-to-mrtest branch May 27, 2026 14:36
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.

3 participants