Skip to content

Run the client/server integration tests through ctest (+ macOS build fixes) - #31

Open
Upabjojr wants to merge 2 commits into
tomluchowski:shaders-improvementfrom
Upabjojr:split/ctest-server-launcher
Open

Run the client/server integration tests through ctest (+ macOS build fixes)#31
Upabjojr wants to merge 2 commits into
tomluchowski:shaders-improvementfrom
Upabjojr:split/ctest-server-launcher

Conversation

@Upabjojr

@Upabjojr Upabjojr commented Aug 6, 2026

Copy link
Copy Markdown

Follow-up to the discussion in #26 (#26 (comment)): the aa-*/ab-* tests are integration tests — each test binary is only the client side of a game, and expects a headless server already listening on localhost:32222, hosting the multiplayer level named after the two-letter test prefix (levels/multiplayer/aa.level, ab.level). Running the binaries directly can only fail with Could not connect to distant server status=3.

Until now the only way to run them correctly was scripts/unix/run_unit_tests.sh (or scripts/win32/OpenDungeonsTests.bat), which starts opendungeons-plus --server <prefix>.level --port 32222 around each test. This PR makes a plain ctest do that automatically:

  • scripts/unix/run_boost_test_with_server.sh (new): starts the headless server for a given level, runs the test command, then shuts the server down. It propagates the test's exit code, fails fast if the server dies on startup, and cleans up the server even if interrupted.

  • source/tests/CMakeLists.txt: the integration tests are registered with that script as their LAUNCHER (a facility add_boost_test already supported), passing $<TARGET_FILE:opendungeons-plus> and the right level. The tests also get a shared RESOURCE_LOCK, so ctest -j N never runs two of them at once on the same port. The 00-* unit tests are untouched, and on Windows everything stays as before.
    A second commit fixes building on macOS, which is what let me build and validate the test harness on this machine:

  • source/utils/Helper.{h,cpp}: enables the existing OpenBSD-only toString(size_t) overload on macOS too, which has the same LP64 setup (size_t is unsigned long, matching neither uint32_t nor uint64_t), so several files fail to compile with clang without it.

  • source/utils/ResourceManager.cpp: std::string(applePath + "/") is pointer arithmetic and does not compile; changed to std::string(applePath) + "/".

  • CMakeLists.txt: on Apple, build the already-existing StackTraceStub.cpp instead of StackTraceUnix.cpp, which relies on struct sigcontext and the deprecated ucontext routines that do not exist on macOS.

Validated locally on macOS: built with -DOD_BUILD_TESTING=ON and ran the suite through plain ctest — the server is started and stopped automatically around each integration test.

run_unit_tests.sh still works as before for running the test binaries straight from a build directory.

🤖 Generated with Claude Code

Francesco Bonazzi and others added 2 commits August 6, 2026 17:36
The aa-*/ab-* tests are integration tests: each test binary is a game
client that expects a headless server on localhost:32222 hosting the
level named after the two-letter test prefix. Until now only
run_unit_tests.sh started that server, so running the binaries directly
(or through ctest) could only fail with "Could not connect to distant
server".

Register a launcher script for those tests that starts the server, runs
the test and shuts the server down, using the LAUNCHER facility
add_boost_test already had. A shared RESOURCE_LOCK keeps ctest -j from
running two servers on the same port. The 00-* unit tests and the
Windows workflow are unchanged.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- Helper: enable the existing OpenBSD toString(size_t) overload on
  macOS too; both are LP64 systems where size_t is unsigned long while
  uint64_t is unsigned long long, so size_t matches no fixed-width
  overload and calls are ambiguous.
- ResourceManager: std::string(applePath + "/") is pointer arithmetic
  and does not compile; also share the "data/plugins.cfg in the current
  folder win" logic between all platforms so a build can run in place
  outside an .app bundle.
- CMakeLists: on Apple build the already existing StackTraceStub.cpp;
  StackTraceUnix.cpp needs struct sigcontext and the deprecated
  ucontext routines, neither of which exists on macOS.
- BoostTestTargets: use the dynamic Boost.Test config on Apple as well;
  the "included" fallback compiles the whole framework into every file
  including BoostTestTargetConfig.h, giving duplicate symbols in
  multi-file tests like the aa-*/ab-* ones.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.

1 participant