Add automated test suite for DLL core systems - #1211
Open
acato wants to merge 5 commits into
Open
Conversation
Custom MinUnit-derived C++03 test framework with 35 tests across 6 suites covering EnumMap, JustInTimeArray, Coordinates, CvTradeRoute sentinels, and CvIdVector. Tests run at startup in Assert/Debug builds after XML load, logging results to Logs\WTPTests.log. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
C++ tests (10) validate XML cross-references at startup: profession yields, building classes, unit professions, father CivEffects/categories, yield costs, equipment amounts, terrain yields, and trade sentinels. Perl scripts: test_determinism.pl detects non-deterministic calls (rand/srand/time/GetTickCount) outside allowed files; test_text_keys.pl verifies TXT_KEY references in data XML have matching text definitions. Both run as part of the test_DllExport build target. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Phase 3: MemoryStream (in-memory FDataStreamBase) with 23 round-trip tests covering primitives, strings, IDInfo, JustInTimeArray, and enum types. Fix XMLIntegrity test: allow NO_YIELD (-1) in profession yield lists, as the game code explicitly checks and skips it. Fix int-to-enum casts for VC++ 2003 strict type checking. Fix Savegame test: JustInTimeArray::Read() always allocates, even for empty arrays — removed incorrect !isAllocated() assertion. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Phase 4: CvRandom determinism tests — seed reproducibility, range bounds, peek non-advancement, float output, and state round-trips (576 checks). Phase 5: Python-side test suite (WTPTests.py) validating the DLL-Python bridge and XML data consistency — profession yields, building classes, unit professions, father categories, terrain yields, civilization info. Runnable from debug console: import WTPTests; WTPTests.runAllTests() Also fixes WTPTests.log double-nesting (gDLL->logMsg already writes to the Logs/ directory). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Strip references to AFRICA_CITY_ID, PORT_ROYAL_CITY_ID, and isOffMapTradeLocation() from test files — these depend on the trade route feature branch and don't belong in the test-only PR. Add test suite design document explaining framework principles, usage, and examples for extending the suite. Co-Authored-By: Claude Opus 4.6 <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.
Summary
WTPTestFramework.h) that runs automatically on game launch in Assert builds, with zero overhead in Release/FinalReleaseTest suites
Files added
DLLSources/WTPTestFramework.h/.cpp— framework macros and reportingDLLSources/TestDataStructures.cpp— EnumMap, JIT array, coordinates, trade route, ID vector testsDLLSources/TestXMLIntegrity.cpp— XML cross-reference validationDLLSources/TestSavegame.cpp— MemoryStream + round-trip serialization testsDLLSources/TestDeterminism.cpp— CvRandom determinism testsbin/test_determinism.pl— build-time scan for non-deterministic stdlib callsbin/test_text_keys.pl— build-time TXT_KEY coverage checkAssets/Python/_DebugTools/WTPTests.py— Python test suitedocs/test-suite-design.md— design documentTest plan
Logs/WTPTests.log#ifdef FASSERT_ENABLE)🤖 Generated with Claude Code