feat(Tests): Add module test integration to build system

Implements CMake infrastructure for modules to register tests with the
core test suite using global properties pattern.

Modules can now register test sources and includes by setting:
- ACORE_MODULE_TEST_SOURCES global property
- ACORE_MODULE_TEST_INCLUDES global property

The test system retrieves these properties after unit_tests target is
created and automatically includes them in the build. This solves the
timing issue where module CMake runs before test targets exist.

Benefits:
- Modules can provide their own unit/integration tests
- Tests run as part of standard test suite
- No manual test registration required in core
- Module tests have access to module code via modules library
This commit is contained in:
blinkysc 2025-11-05 07:10:06 -06:00
parent cf776898fe
commit cd2fb530e1

View File

@ -31,6 +31,26 @@ target_link_libraries(
game-interface
)
# Add module test sources if any modules registered tests
get_property(MODULE_TEST_SOURCES GLOBAL PROPERTY ACORE_MODULE_TEST_SOURCES)
get_property(MODULE_TEST_INCLUDES GLOBAL PROPERTY ACORE_MODULE_TEST_INCLUDES)
if(MODULE_TEST_SOURCES)
target_sources(unit_tests PRIVATE ${MODULE_TEST_SOURCES})
message(STATUS "Added module tests to unit_tests target")
endif()
if(MODULE_TEST_INCLUDES)
list(REMOVE_DUPLICATES MODULE_TEST_INCLUDES)
target_include_directories(unit_tests PRIVATE ${MODULE_TEST_INCLUDES})
message(STATUS "Added module test includes to unit_tests target")
endif()
# Link modules library to tests so module code is available
if(TARGET modules)
target_link_libraries(unit_tests modules)
endif()
add_test(
NAME
unit