Skip to content

Commit

Permalink
ci: Allow and run integration tests on every platform (#9607)
Browse files Browse the repository at this point in the history
  • Loading branch information
quyykk committed Dec 26, 2023
1 parent fd4eec5 commit 7842772
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 29 deletions.
2 changes: 0 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ cmake_dependent_option(ES_GLES "Build the game with OpenGL ES" OFF UNIX OFF)
cmake_dependent_option(ES_FLATPAK "Build the game inside the Flatpak runtime" OFF UNIX OFF)
cmake_dependent_option(ES_STEAM "Build the game for the Steam Linux runtime" OFF UNIX OFF)
cmake_dependent_option(ES_USE_SYSTEM_LIBRARIES "Use system libraries instead of the vcpkg ones." ON UNIX OFF)
cmake_dependent_option(ES_USE_OFFSCREEN
"Use SDL's offscreen backend instead of Xvfb for the integration tests" OFF UNIX OFF)
cmake_dependent_option(ES_CREATE_BUNDLE "Create a Bundle instead of an executable. Not suitable for development purposes." OFF APPLE OFF)

# Support Debug and Release configurations.
Expand Down
32 changes: 28 additions & 4 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,12 @@
"configurePreset": "macos",
"inherits": "benchmark"
},
{
"name": "macos-integration",
"displayName": "Integration Tests",
"configurePreset": "macos",
"inherits": "integration"
},
{
"name": "macos-integration-debug",
"displayName": "Integration Tests (Debug)",
Expand All @@ -704,6 +710,12 @@
"configurePreset": "macos-arm",
"inherits": "benchmark"
},
{
"name": "macos-arm-integration",
"displayName": "Integration Tests",
"configurePreset": "macos-arm",
"inherits": "integration"
},
{
"name": "macos-arm-integration-debug",
"displayName": "Integration Tests (Debug)",
Expand All @@ -728,6 +740,12 @@
"configurePreset": "clang-cl",
"inherits": "benchmark"
},
{
"name": "clang-cl-integration",
"displayName": "Integration Tests",
"configurePreset": "clang-cl",
"inherits": "integration"
},
{
"name": "clang-cl-integration-debug",
"displayName": "Integration Tests (Debug)",
Expand All @@ -752,6 +770,12 @@
"configurePreset": "mingw",
"inherits": "benchmark"
},
{
"name": "mingw-integration",
"displayName": "Integration Tests",
"configurePreset": "mingw",
"inherits": "integration"
},
{
"name": "mingw-integration-debug",
"displayName": "Integration Tests (Debug)",
Expand Down Expand Up @@ -798,7 +822,7 @@
"name": "linux-gles-ci",
"displayName": "Linux GLES CI Tests",
"configurePreset": "linux-gles-ci",
"inherits": "ci"
"inherits": "ci-integration"
},
{
"name": "linux-gles-ci-benchmark",
Expand All @@ -810,7 +834,7 @@
"name": "macos-ci",
"displayName": "MacOS CI Tests",
"configurePreset": "macos-ci",
"inherits": "ci"
"inherits": "ci-integration"
},
{
"name": "macos-ci-benchmark",
Expand All @@ -822,7 +846,7 @@
"name": "clang-cl-ci",
"displayName": "VS CI Tests",
"configurePreset": "clang-cl-ci",
"inherits": "ci"
"inherits": "ci-integration"
},
{
"name": "clang-cl-ci-benchmark",
Expand All @@ -834,7 +858,7 @@
"name": "mingw-ci",
"displayName": "Mingw CI Tests",
"configurePreset": "mingw-ci",
"inherits": "ci"
"inherits": "ci-integration"
},
{
"name": "mingw-ci-benchmark",
Expand Down
2 changes: 1 addition & 1 deletion source/GameWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ bool GameWindow::Init(bool headless)

// The main window spawns visibly at this point.
mainWindow = SDL_CreateWindow("Endless Sky", SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED, windowWidth, windowHeight, flags);
SDL_WINDOWPOS_UNDEFINED, windowWidth, windowHeight, headless ? 0 : flags);

if(!mainWindow)
{
Expand Down
32 changes: 11 additions & 21 deletions tests/integration/IntegrationTests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,40 +13,30 @@ file(REMOVE "${CMAKE_CURRENT_SOURCE_DIR}/integration/config/errors.txt")
string(REPLACE "\n" ";" INTEGRATION_TESTS_LIST "${INTEGRATION_TESTS}")
set(TEST_CONFIGS "${BINARY_PATH}/integration_configs")

# Choose between using the offscreen backend and Xvfb.
if(ES_USE_OFFSCREEN)
set(OFFSCREEN "ENVIRONMENT \"SDL_VIDEODRIVER=offscreen\"")
else()
set(XFVB "xvfb-run --auto-servernum \"--server-args=+extension GLX +render -noreset\"")
endif()

# Add each test as CTest.
foreach(test ${INTEGRATION_TESTS_LIST})
if(UNIX AND NOT APPLE)
# Launches the integration tests in release mode: In the background and as fast as possible.
set(ADD_TEST
# Launches the integration tests in release mode: In the background and as fast as possible.
set(ADD_TEST
"add_test([==[${test}]==] \"${CMAKE_COMMAND}\"
-DXFVB=${XFVB}
-DES=${ES}
-DTEST_CONFIGS=${TEST_CONFIGS}
\"-DES=${ES}\"
\"-DTEST_CONFIGS=${TEST_CONFIGS}\"
\"-Dtest=${test}\"
-DRESOURCE_PATH=${RESOURCE_PATH}
-DES_CONFIG=${ES_CONFIG}
\"-DRESOURCE_PATH=${RESOURCE_PATH}\"
\"-DES_CONFIG=${ES_CONFIG}\"
-P \"${CMAKE_SOURCE_DIR}/integration/RunIntegrationTest.cmake\")")
set(SET_TEST_PROPS
"set_tests_properties([==[${test}]==] PROPERTIES
WORKING_DIRECTORY \"${CMAKE_CURRENT_SOURCE_DIR}\"
LABELS integration ${OFFSCREEN})")
endif()
LABELS integration)")

# Launches the integration tests in debug mode, so that they can be followed.
set(ADD_TEST_DEBUG
"add_test([==[[debug] ${test}]==] \"${CMAKE_COMMAND}\"
-DES=${ES}
-DTEST_CONFIGS=${TEST_CONFIGS}
\"-DES=${ES}\"
\"-DTEST_CONFIGS=${TEST_CONFIGS}\"
\"-Dtest=${test}\"
-DRESOURCE_PATH=${RESOURCE_PATH}
-DES_CONFIG=${ES_CONFIG}
\"-DRESOURCE_PATH=${RESOURCE_PATH}\"
\"-DES_CONFIG=${ES_CONFIG}\"
-DDEBUG=--debug
-P \"${CMAKE_SOURCE_DIR}/integration/RunIntegrationTest.cmake\")")
set(SET_TEST_PROPS_DEBUG
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/RunIntegrationTest.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ file(COPY "${ES_CONFIG}" DESTINATION "${TEST_CONFIGS}")
file(RENAME "${TEST_CONFIGS}/config" "${TEST_CONFIG}")

# Run the integration test
execute_process(COMMAND $ENV{ES_INTEGRATION_PREFIX} ${XFVB} "${ES}" --config "${TEST_CONFIG}" --resources "${RESOURCE_PATH}" --test "${test}" ${DEBUG}
execute_process(COMMAND $ENV{ES_INTEGRATION_PREFIX} "${ES}" --config "${TEST_CONFIG}" --resources "${RESOURCE_PATH}" --test "${test}" ${DEBUG}
OUTPUT_VARIABLE TEST_OUTPUT
ERROR_VARIABLE TEST_OUTPUT
RESULT_VARIABLE TEST_RESULT)
Expand Down

0 comments on commit 7842772

Please sign in to comment.