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_ENABLE_EXPERIMENTAL_TESTS=OFF `
|
||||||
-DYAZE_INSTALL_LIB=OFF `
|
-DYAZE_INSTALL_LIB=OFF `
|
||||||
-DYAZE_MINIMAL_BUILD=OFF `
|
-DYAZE_MINIMAL_BUILD=OFF `
|
||||||
-DGTEST_DISCOVER_TESTS_DISCOVERY_MODE=POST_BUILD `
|
|
||||||
-G "${{ matrix.cmake_generator }}" `
|
-G "${{ matrix.cmake_generator }}" `
|
||||||
-A ${{ matrix.cmake_generator_platform }}
|
-A ${{ matrix.cmake_generator_platform }}
|
||||||
} else {
|
} else {
|
||||||
@@ -249,7 +248,6 @@ jobs:
|
|||||||
-DYAZE_ENABLE_EXPERIMENTAL_TESTS=OFF `
|
-DYAZE_ENABLE_EXPERIMENTAL_TESTS=OFF `
|
||||||
-DYAZE_INSTALL_LIB=OFF `
|
-DYAZE_INSTALL_LIB=OFF `
|
||||||
-DYAZE_MINIMAL_BUILD=ON `
|
-DYAZE_MINIMAL_BUILD=ON `
|
||||||
-DGTEST_DISCOVER_TESTS_DISCOVERY_MODE=POST_BUILD `
|
|
||||||
-G "${{ matrix.cmake_generator }}" `
|
-G "${{ matrix.cmake_generator }}" `
|
||||||
-A ${{ matrix.cmake_generator_platform }}
|
-A ${{ matrix.cmake_generator_platform }}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,107 +11,109 @@ foreach (file
|
|||||||
list(APPEND YAZE_SRC_FILES ${CMAKE_SOURCE_DIR}/src/${file})
|
list(APPEND YAZE_SRC_FILES ${CMAKE_SOURCE_DIR}/src/${file})
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
# Main test executable with enhanced argument handling for AI agents
|
# Only build test executable if tests are enabled
|
||||||
# Use CI version for minimal builds, full version for development
|
if(YAZE_BUILD_TESTS)
|
||||||
if(YAZE_MINIMAL_BUILD)
|
# Main test executable with enhanced argument handling for AI agents
|
||||||
# CI/Minimal build: use simplified test executable
|
# Use CI version for minimal builds, full version for development
|
||||||
add_executable(
|
if(YAZE_MINIMAL_BUILD)
|
||||||
yaze_test
|
# CI/Minimal build: use simplified test executable
|
||||||
yaze_test_ci.cc
|
add_executable(
|
||||||
test_editor.cc
|
yaze_test
|
||||||
test_editor.h
|
yaze_test_ci.cc
|
||||||
testing.h
|
test_editor.cc
|
||||||
test_utils.h
|
test_editor.h
|
||||||
|
testing.h
|
||||||
# Unit Tests
|
test_utils.h
|
||||||
unit/core/asar_wrapper_test.cc
|
|
||||||
unit/core/hex_test.cc
|
|
||||||
unit/rom/rom_test.cc
|
|
||||||
unit/gfx/snes_tile_test.cc
|
|
||||||
unit/gfx/compression_test.cc
|
|
||||||
unit/gfx/snes_palette_test.cc
|
|
||||||
unit/zelda3/message_test.cc
|
|
||||||
unit/zelda3/overworld_test.cc
|
|
||||||
unit/zelda3/object_parser_test.cc
|
|
||||||
unit/zelda3/object_parser_structs_test.cc
|
|
||||||
unit/zelda3/sprite_builder_test.cc
|
|
||||||
unit/zelda3/sprite_position_test.cc
|
|
||||||
unit/zelda3/test_dungeon_objects.cc
|
|
||||||
unit/zelda3/dungeon_component_unit_test.cc
|
|
||||||
|
|
||||||
# Integration Tests
|
# Unit Tests
|
||||||
integration/asar_integration_test.cc
|
unit/core/asar_wrapper_test.cc
|
||||||
integration/asar_rom_test.cc
|
unit/core/hex_test.cc
|
||||||
integration/dungeon_editor_test.cc
|
unit/rom/rom_test.cc
|
||||||
integration/dungeon_editor_test.h
|
unit/gfx/snes_tile_test.cc
|
||||||
integration/editor/tile16_editor_test.cc
|
unit/gfx/compression_test.cc
|
||||||
integration/editor/editor_integration_test.cc
|
unit/gfx/snes_palette_test.cc
|
||||||
integration/editor/editor_integration_test.h
|
unit/zelda3/message_test.cc
|
||||||
|
unit/zelda3/overworld_test.cc
|
||||||
# E2E Tests (excluded in CI builds)
|
unit/zelda3/object_parser_test.cc
|
||||||
e2e/rom_dependent/e2e_rom_test.cc
|
unit/zelda3/object_parser_structs_test.cc
|
||||||
e2e/zscustomoverworld/zscustomoverworld_upgrade_test.cc
|
unit/zelda3/sprite_builder_test.cc
|
||||||
|
unit/zelda3/sprite_position_test.cc
|
||||||
# Legacy Integration Tests (to be migrated)
|
unit/zelda3/test_dungeon_objects.cc
|
||||||
unit/zelda3/comprehensive_integration_test.cc
|
unit/zelda3/dungeon_component_unit_test.cc
|
||||||
unit/zelda3/overworld_integration_test.cc
|
|
||||||
unit/zelda3/dungeon_integration_test.cc
|
# Integration Tests
|
||||||
unit/zelda3/dungeon_editor_system_integration_test.cc
|
integration/asar_integration_test.cc
|
||||||
unit/zelda3/dungeon_object_renderer_integration_test.cc
|
integration/asar_rom_test.cc
|
||||||
unit/zelda3/dungeon_object_renderer_mock_test.cc
|
integration/dungeon_editor_test.cc
|
||||||
unit/zelda3/dungeon_object_rendering_tests.cc
|
integration/dungeon_editor_test.h
|
||||||
unit/zelda3/dungeon_room_test.cc
|
integration/editor/tile16_editor_test.cc
|
||||||
)
|
integration/editor/editor_integration_test.cc
|
||||||
else()
|
integration/editor/editor_integration_test.h
|
||||||
# Development build: use full-featured test executable
|
|
||||||
add_executable(
|
# E2E Tests (excluded in CI builds)
|
||||||
yaze_test
|
e2e/rom_dependent/e2e_rom_test.cc
|
||||||
yaze_test.cc
|
e2e/zscustomoverworld/zscustomoverworld_upgrade_test.cc
|
||||||
test_editor.cc
|
|
||||||
test_editor.h
|
# Legacy Integration Tests (to be migrated)
|
||||||
testing.h
|
unit/zelda3/comprehensive_integration_test.cc
|
||||||
test_utils.h
|
unit/zelda3/overworld_integration_test.cc
|
||||||
|
unit/zelda3/dungeon_integration_test.cc
|
||||||
# Unit Tests
|
unit/zelda3/dungeon_editor_system_integration_test.cc
|
||||||
unit/core/asar_wrapper_test.cc
|
unit/zelda3/dungeon_object_renderer_integration_test.cc
|
||||||
unit/core/hex_test.cc
|
unit/zelda3/dungeon_object_renderer_mock_test.cc
|
||||||
unit/rom/rom_test.cc
|
unit/zelda3/dungeon_object_rendering_tests.cc
|
||||||
unit/gfx/snes_tile_test.cc
|
unit/zelda3/dungeon_room_test.cc
|
||||||
unit/gfx/compression_test.cc
|
)
|
||||||
unit/gfx/snes_palette_test.cc
|
else()
|
||||||
unit/zelda3/message_test.cc
|
# Development build: use full-featured test executable
|
||||||
unit/zelda3/overworld_test.cc
|
add_executable(
|
||||||
unit/zelda3/object_parser_test.cc
|
yaze_test
|
||||||
unit/zelda3/object_parser_structs_test.cc
|
yaze_test.cc
|
||||||
unit/zelda3/sprite_builder_test.cc
|
test_editor.cc
|
||||||
unit/zelda3/sprite_position_test.cc
|
test_editor.h
|
||||||
unit/zelda3/test_dungeon_objects.cc
|
testing.h
|
||||||
unit/zelda3/dungeon_component_unit_test.cc
|
test_utils.h
|
||||||
|
|
||||||
# Integration Tests
|
# Unit Tests
|
||||||
integration/asar_integration_test.cc
|
unit/core/asar_wrapper_test.cc
|
||||||
integration/asar_rom_test.cc
|
unit/core/hex_test.cc
|
||||||
integration/dungeon_editor_test.cc
|
unit/rom/rom_test.cc
|
||||||
integration/dungeon_editor_test.h
|
unit/gfx/snes_tile_test.cc
|
||||||
integration/editor/tile16_editor_test.cc
|
unit/gfx/compression_test.cc
|
||||||
integration/editor/editor_integration_test.cc
|
unit/gfx/snes_palette_test.cc
|
||||||
integration/editor/editor_integration_test.h
|
unit/zelda3/message_test.cc
|
||||||
|
unit/zelda3/overworld_test.cc
|
||||||
# E2E Tests (included in development builds)
|
unit/zelda3/object_parser_test.cc
|
||||||
e2e/rom_dependent/e2e_rom_test.cc
|
unit/zelda3/object_parser_structs_test.cc
|
||||||
e2e/zscustomoverworld/zscustomoverworld_upgrade_test.cc
|
unit/zelda3/sprite_builder_test.cc
|
||||||
|
unit/zelda3/sprite_position_test.cc
|
||||||
# Legacy Integration Tests (to be migrated)
|
unit/zelda3/test_dungeon_objects.cc
|
||||||
unit/zelda3/comprehensive_integration_test.cc
|
unit/zelda3/dungeon_component_unit_test.cc
|
||||||
unit/zelda3/overworld_integration_test.cc
|
|
||||||
unit/zelda3/dungeon_integration_test.cc
|
# Integration Tests
|
||||||
unit/zelda3/dungeon_editor_system_integration_test.cc
|
integration/asar_integration_test.cc
|
||||||
unit/zelda3/dungeon_object_renderer_integration_test.cc
|
integration/asar_rom_test.cc
|
||||||
unit/zelda3/dungeon_object_renderer_mock_test.cc
|
integration/dungeon_editor_test.cc
|
||||||
unit/zelda3/dungeon_object_rendering_tests.cc
|
integration/dungeon_editor_test.h
|
||||||
unit/zelda3/dungeon_room_test.cc
|
integration/editor/tile16_editor_test.cc
|
||||||
)
|
integration/editor/editor_integration_test.cc
|
||||||
endif()
|
integration/editor/editor_integration_test.h
|
||||||
|
|
||||||
|
# E2E Tests (included in development builds)
|
||||||
|
e2e/rom_dependent/e2e_rom_test.cc
|
||||||
|
e2e/zscustomoverworld/zscustomoverworld_upgrade_test.cc
|
||||||
|
|
||||||
|
# Legacy Integration Tests (to be migrated)
|
||||||
|
unit/zelda3/comprehensive_integration_test.cc
|
||||||
|
unit/zelda3/overworld_integration_test.cc
|
||||||
|
unit/zelda3/dungeon_integration_test.cc
|
||||||
|
unit/zelda3/dungeon_editor_system_integration_test.cc
|
||||||
|
unit/zelda3/dungeon_object_renderer_integration_test.cc
|
||||||
|
unit/zelda3/dungeon_object_renderer_mock_test.cc
|
||||||
|
unit/zelda3/dungeon_object_rendering_tests.cc
|
||||||
|
unit/zelda3/dungeon_room_test.cc
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
# Add vanilla value extraction utility (only for local development with ROM access)
|
# Add vanilla value extraction utility (only for local development with ROM access)
|
||||||
if(NOT YAZE_MINIMAL_BUILD AND YAZE_ENABLE_ROM_TESTS)
|
if(NOT YAZE_MINIMAL_BUILD AND YAZE_ENABLE_ROM_TESTS)
|
||||||
@@ -153,63 +155,65 @@ if(NOT YAZE_MINIMAL_BUILD AND YAZE_ENABLE_ROM_TESTS)
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_include_directories(
|
# Configure test executable only when tests are enabled
|
||||||
yaze_test PUBLIC
|
target_include_directories(
|
||||||
${CMAKE_SOURCE_DIR}/src/app/
|
yaze_test PUBLIC
|
||||||
${CMAKE_SOURCE_DIR}/src/lib/
|
${CMAKE_SOURCE_DIR}/src/app/
|
||||||
${CMAKE_SOURCE_DIR}/incl/
|
${CMAKE_SOURCE_DIR}/src/lib/
|
||||||
${CMAKE_SOURCE_DIR}/src/
|
${CMAKE_SOURCE_DIR}/incl/
|
||||||
${CMAKE_SOURCE_DIR}/test/
|
${CMAKE_SOURCE_DIR}/src/
|
||||||
${CMAKE_SOURCE_DIR}/src/lib/imgui_test_engine
|
${CMAKE_SOURCE_DIR}/test/
|
||||||
${CMAKE_SOURCE_DIR}/src/lib/asar/src
|
${CMAKE_SOURCE_DIR}/src/lib/imgui_test_engine
|
||||||
${CMAKE_SOURCE_DIR}/src/lib/asar/src/asar
|
${CMAKE_SOURCE_DIR}/src/lib/asar/src
|
||||||
${CMAKE_SOURCE_DIR}/src/lib/asar/src/asar-dll-bindings/c
|
${CMAKE_SOURCE_DIR}/src/lib/asar/src/asar
|
||||||
${SDL2_INCLUDE_DIR}
|
${CMAKE_SOURCE_DIR}/src/lib/asar/src/asar-dll-bindings/c
|
||||||
${PNG_INCLUDE_DIRS}
|
${SDL2_INCLUDE_DIR}
|
||||||
${PROJECT_BINARY_DIR}
|
${PNG_INCLUDE_DIRS}
|
||||||
)
|
${PROJECT_BINARY_DIR}
|
||||||
|
)
|
||||||
|
|
||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
yaze_test
|
yaze_test
|
||||||
${SDL_TARGETS}
|
${SDL_TARGETS}
|
||||||
asar-static
|
asar-static
|
||||||
${ABSL_TARGETS}
|
${ABSL_TARGETS}
|
||||||
${PNG_LIBRARIES}
|
${PNG_LIBRARIES}
|
||||||
${OPENGL_LIBRARIES}
|
${OPENGL_LIBRARIES}
|
||||||
${CMAKE_DL_LIBS}
|
${CMAKE_DL_LIBS}
|
||||||
ImGui
|
ImGui
|
||||||
gmock_main
|
gmock_main
|
||||||
gmock
|
gmock
|
||||||
gtest_main
|
gtest_main
|
||||||
gtest
|
gtest
|
||||||
)
|
)
|
||||||
|
|
||||||
# Link core library for essential functionality (BPS, ASAR, etc.)
|
# Link core library for essential functionality (BPS, ASAR, etc.)
|
||||||
if(YAZE_BUILD_LIB)
|
if(YAZE_BUILD_LIB)
|
||||||
target_link_libraries(yaze_test yaze_core)
|
target_link_libraries(yaze_test yaze_core)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Conditionally link ImGuiTestEngine only when UI tests are enabled
|
# Conditionally link ImGuiTestEngine only when UI tests are enabled
|
||||||
if(YAZE_ENABLE_UI_TESTS)
|
if(YAZE_ENABLE_UI_TESTS)
|
||||||
target_link_libraries(yaze_test ${IMGUI_TEST_ENGINE_TARGET})
|
target_link_libraries(yaze_test ${IMGUI_TEST_ENGINE_TARGET})
|
||||||
target_compile_definitions(yaze_test PRIVATE ${IMGUI_TEST_ENGINE_DEFINITIONS})
|
target_compile_definitions(yaze_test PRIVATE ${IMGUI_TEST_ENGINE_DEFINITIONS})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# ROM Testing Configuration
|
# ROM Testing Configuration
|
||||||
if(YAZE_ENABLE_ROM_TESTS)
|
if(YAZE_ENABLE_ROM_TESTS)
|
||||||
target_compile_definitions(yaze_test PRIVATE
|
target_compile_definitions(yaze_test PRIVATE
|
||||||
YAZE_ENABLE_ROM_TESTS=1
|
YAZE_ENABLE_ROM_TESTS=1
|
||||||
YAZE_TEST_ROM_PATH="${YAZE_TEST_ROM_PATH}"
|
YAZE_TEST_ROM_PATH="${YAZE_TEST_ROM_PATH}"
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Platform-specific definitions
|
# Platform-specific definitions
|
||||||
if(UNIX AND NOT APPLE)
|
if(UNIX AND NOT APPLE)
|
||||||
target_compile_definitions(yaze_test PRIVATE "linux" "stricmp=strcasecmp")
|
target_compile_definitions(yaze_test PRIVATE "linux" "stricmp=strcasecmp")
|
||||||
elseif(APPLE)
|
elseif(APPLE)
|
||||||
target_compile_definitions(yaze_test PRIVATE "MACOS" "stricmp=strcasecmp")
|
target_compile_definitions(yaze_test PRIVATE "MACOS" "stricmp=strcasecmp")
|
||||||
elseif(WIN32)
|
elseif(WIN32)
|
||||||
target_compile_definitions(yaze_test PRIVATE "WINDOWS")
|
target_compile_definitions(yaze_test PRIVATE "WINDOWS")
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Configure test discovery with efficient labeling for CI/CD
|
# Configure test discovery with efficient labeling for CI/CD
|
||||||
@@ -219,6 +223,9 @@ if(YAZE_BUILD_TESTS)
|
|||||||
|
|
||||||
# Discover all tests with default properties
|
# Discover all tests with default properties
|
||||||
gtest_discover_tests(yaze_test)
|
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()
|
endif()
|
||||||
|
|
||||||
# Test organization and labeling for CI/CD
|
# Test organization and labeling for CI/CD
|
||||||
|
|||||||
Reference in New Issue
Block a user