Skip to content

Migrate tests to Catch2 v3 - #512

Open
stevekennedyuk wants to merge 6 commits into
openstreetmap:masterfrom
stevekennedyuk:pr/catch2-v3
Open

stevekennedyuk wants to merge 6 commits into
openstreetmap:masterfrom
stevekennedyuk:pr/catch2-v3

Conversation

@stevekennedyuk

@stevekennedyuk stevekennedyuk commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Moves the tests from Catch2 v2.13.10, which is end-of-life, to v3.16.0.

Depends on the CMake PR, #511, which it's stacked on; its own change is the last commit. Most of the diff is the vendored Catch2 sources.

  • Vendors the official v3.16.0 amalgamated build (tests/catch/catch_amalgamated.{hpp,cpp}, with its LICENSE and a README recording the upstream tag and commit). It is compiled once rather than in every test file, for both CMake and Autotools.
  • Catch::Matchers::Contains → ContainsSubstring (including the new unit_test_*.cpp suites); explicit main() functions instead of CATCH_CONFIG_MAIN/CATCH_CONFIG_RUNNER.
  • Default CMAKE_CXX_STANDARD 11 → 14 (v3's minimum; mapnik-config already reports -std=c++14 for Mapnik 3). An existing build directory with 11 cached is bumped with a warning rather than failing.

Every suite runs the same number of test cases and assertions as under v2 (e.g. gen_tile_test: 26559 assertions in 12 test cases; unit_tests: 493 assertions in 7 test cases).

Rebased onto the current master (via #511).

🤖 Generated with Claude Code

https://claude.ai/code/session_01YForD7qSL9LT6FhMuAoKPV

@codecov-commenter

codecov-commenter commented Oct 10, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.84%. Comparing base (c4e3e62) to head (4e90fa7).
⚠️ Report is 54 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #512      +/-   ##
==========================================
+ Coverage   81.54%   81.84%   +0.30%     
==========================================
  Files          24       24              
  Lines        5645     5353     -292     
==========================================
- Hits         4603     4381     -222     
+ Misses       1042      972      -70     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

stevekennedyuk and others added 6 commits October 22, 2026 10:42
- Compile sources shared between targets once via internal OBJECT
  libraries (PIC so they also link into mod_tile.so). A full build with
  tests goes from 104 to 37 compile steps.
- Generate config.h into the build tree instead of includes/, so the
  source tree stays clean and several build dirs can coexist.
- Bump cmake_minimum_required to 3.15 (list(PREPEND) needs it).
- find_package(PkgConfig) explicitly (pkg_get_variable is used directly).
- Drop link_directories(${CMAKE_LIBRARY_PATH}).
- Use option() for boolean switches.
- New options: ENABLE_WARNINGS, ENABLE_WERROR, ENABLE_SANITIZERS.
- TILE_LOAD_DIRECTORY / TILE_LOAD_FILENAME can be set to override the
  build-host /etc/os-release detection (packaging, cross builds).
- Print a feature summary of which optional backends were found.
- Add CMakePresets.json: default, dev, asan, tsan.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YForD7qSL9LT6FhMuAoKPV
Log messages and storage IDs are deliberately truncated to
PATH_MAX-sized buffers, so this heuristic only produces false
positives here. Only added when the compiler supports the flag.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YForD7qSL9LT6FhMuAoKPV
- configure.ac reads the version from CMakeLists.txt so it is only
  defined in one place (and fails loudly if it cannot).
- Bug report URL points at GitHub issues rather than the old trac.
- Use pkg-config for iniparser when a .pc file is available, falling
  back to the previous AC_CHECK_LIB probe.
- configure prints a deprecation warning pointing at CMake; README
  marks Autotools as deprecated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YForD7qSL9LT6FhMuAoKPV
- With ENABLE_SANITIZERS containing "address", tests run with the ASan
  runtime in LD_PRELOAD, so the system (uninstrumented) httpd can load
  the instrumented mod_tile.so. Without this every Apache-based test
  fails under ASan.
- TSan cannot be preloaded into uninstrumented processes, so the tsan
  test preset only runs the unit test executables.
- tests/tsan.supp suppresses a lock-order report inside GDAL's plugin
  initialisation (on renderd's main thread, before any rendering).
- The asan test preset halts on UBSan errors instead of only printing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YForD7qSL9LT6FhMuAoKPV
unit_tests compiles metatile.cpp and parameterize_style.cpp, which use
ICU (via Mapnik) directly. At -O0 GCC does not inline those calls away,
so a Debug build failed to link:

  undefined reference to symbol '_ZNK6icu_7413UnicodeString10doHashCodeEv'
  libicuuc.so.74: error adding symbols: DSO missing from command line

Add ${ICU_LIBRARIES}, as renderd and gen_tile_test already do.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YForD7qSL9LT6FhMuAoKPV
Catch2 v2 is end-of-life. Vendor the official v3.16.0 amalgamated
build (tests/catch/catch_amalgamated.{hpp,cpp}, with LICENSE and a
README recording the upstream tag/commit) in place of catch.hpp.

- Catch's implementation is compiled once (catch2_o, with
  CATCH_AMALGAMATED_CUSTOM_MAIN and third-party warnings suppressed)
  instead of in every test translation unit.
- catch_main.cpp now defines main() explicitly; gen_tile_test keeps
  its own main() and drops CATCH_CONFIG_RUNNER.
- Catch::Matchers::Contains -> ContainsSubstring (v3 rename), including the
  new unit_test_*.cpp suites.
- Autotools: build the Catch2 implementation once (catch2.o) and link it
  into every test binary.
- Explicit #include <fstream> previously pulled in by catch.hpp.
- Default CMAKE_CXX_STANDARD is now 14 (v3 minimum; mapnik-config
  already reports -std=c++14 for Mapnik 3), with a guard that bumps an
  old cached value of 11 rather than failing.

Every suite runs the same number of test cases and assertions as
under v2.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YForD7qSL9LT6FhMuAoKPV
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.

2 participants