Refactor test configuration in CMake to enable conditional test builds
- Updated `CMakeLists.txt` to conditionally build the test executable based on the `YAZE_BUILD_TESTS` flag, enhancing flexibility in test management. - Removed hardcoded test executable configurations and replaced them with conditional logic for minimal and development builds. - Improved organization of test files and dependencies, ensuring that tests are only built and discovered when enabled, streamlining the build process.
This commit is contained in:
2
.github/workflows/release.yml
vendored
2
.github/workflows/release.yml
vendored
@@ -235,7 +235,6 @@ jobs:
|
||||
-DYAZE_ENABLE_EXPERIMENTAL_TESTS=OFF `
|
||||
-DYAZE_INSTALL_LIB=OFF `
|
||||
-DYAZE_MINIMAL_BUILD=OFF `
|
||||
-DGTEST_DISCOVER_TESTS_DISCOVERY_MODE=POST_BUILD `
|
||||
-G "${{ matrix.cmake_generator }}" `
|
||||
-A ${{ matrix.cmake_generator_platform }}
|
||||
} else {
|
||||
@@ -249,7 +248,6 @@ jobs:
|
||||
-DYAZE_ENABLE_EXPERIMENTAL_TESTS=OFF `
|
||||
-DYAZE_INSTALL_LIB=OFF `
|
||||
-DYAZE_MINIMAL_BUILD=ON `
|
||||
-DGTEST_DISCOVER_TESTS_DISCOVERY_MODE=POST_BUILD `
|
||||
-G "${{ matrix.cmake_generator }}" `
|
||||
-A ${{ matrix.cmake_generator_platform }}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,8 @@ foreach (file
|
||||
list(APPEND YAZE_SRC_FILES ${CMAKE_SOURCE_DIR}/src/${file})
|
||||
endforeach()
|
||||
|
||||
# Only build test executable if tests are enabled
|
||||
if(YAZE_BUILD_TESTS)
|
||||
# Main test executable with enhanced argument handling for AI agents
|
||||
# Use CI version for minimal builds, full version for development
|
||||
if(YAZE_MINIMAL_BUILD)
|
||||
@@ -153,6 +155,7 @@ if(NOT YAZE_MINIMAL_BUILD AND YAZE_ENABLE_ROM_TESTS)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Configure test executable only when tests are enabled
|
||||
target_include_directories(
|
||||
yaze_test PUBLIC
|
||||
${CMAKE_SOURCE_DIR}/src/app/
|
||||
@@ -211,6 +214,7 @@ elseif(APPLE)
|
||||
elseif(WIN32)
|
||||
target_compile_definitions(yaze_test PRIVATE "WINDOWS")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Configure test discovery with efficient labeling for CI/CD
|
||||
# Only discover tests if tests are enabled
|
||||
@@ -219,6 +223,9 @@ if(YAZE_BUILD_TESTS)
|
||||
|
||||
# Discover all tests with default properties
|
||||
gtest_discover_tests(yaze_test)
|
||||
else()
|
||||
# Tests are disabled - don't build test executable or discover tests
|
||||
message(STATUS "Tests disabled - skipping test executable and discovery")
|
||||
endif()
|
||||
|
||||
# Test organization and labeling for CI/CD
|
||||
|
||||
Reference in New Issue
Block a user