Run the client/server integration tests through ctest (+ macOS build fixes) - #31
Open
Upabjojr wants to merge 2 commits into
Open
Run the client/server integration tests through ctest (+ macOS build fixes)#31Upabjojr wants to merge 2 commits into
Upabjojr wants to merge 2 commits into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 onlocalhost: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 withCould not connect to distant server status=3.Until now the only way to run them correctly was
scripts/unix/run_unit_tests.sh(orscripts/win32/OpenDungeonsTests.bat), which startsopendungeons-plus --server <prefix>.level --port 32222around each test. This PR makes a plainctestdo 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 theirLAUNCHER(a facilityadd_boost_testalready supported), passing$<TARGET_FILE:opendungeons-plus>and the right level. The tests also get a sharedRESOURCE_LOCK, soctest -j Nnever runs two of them at once on the same port. The00-*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-onlytoString(size_t)overload on macOS too, which has the same LP64 setup (size_tisunsigned long, matching neitheruint32_tnoruint64_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 tostd::string(applePath) + "/".CMakeLists.txt: on Apple, build the already-existingStackTraceStub.cppinstead ofStackTraceUnix.cpp, which relies onstruct sigcontextand the deprecated ucontext routines that do not exist on macOS.Validated locally on macOS: built with
-DOD_BUILD_TESTING=ONand ran the suite through plainctest— the server is started and stopped automatically around each integration test.run_unit_tests.shstill works as before for running the test binaries straight from a build directory.🤖 Generated with Claude Code