The example games failed on the CI runner with "ALSA: Couldn't open audio device" despite SDL_AUDIODRIVER=dummy sitting right there in their CMake -- because it never reached the process. set_tests_properties parses its PROPERTIES arguments as name/value pairs, so a semicolon-separated value list is split and every element after the first is consumed as a bogus property name: ENVIRONMENT kept only SDL_VIDEODRIVER=dummy, and the LD_LIBRARY_PATH prepend list kept only its first directory. ctest --show-only=json-v1 shows the truncation plainly. Nobody could see it. Video survived because SDL3 falls through its driver list to dummy on a headless machine with no hint at all; audio survived on every developer machine because the real device works there; the library paths survived because RPATH covered them. A runner with no sound card was the first environment where any of it mattered. Every list-valued test property now goes through set_property(TEST ...), which takes real list arguments -- the examples' ENVIRONMENT triplets and vendored-path modifications, the suites' LD_LIBRARY_PATH prepends, and the docs harness's driver variables. Verified by property dump (3 environment entries and all 7 prepends present) and by running the example tests with ALSA_CONFIG_PATH=/dev/null, which now pass where a real ALSA open would fail: the dummy driver is finally the one being asked. Co-Authored-By: Claude Code (Claude Fable 5, claude-fable-5) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KzBDV2fqgnUAcqCKqKvc71
63 lines
2.8 KiB
CMake
63 lines
2.8 KiB
CMake
# The UI demo, quoted by the UI chapter's `c excerpt=` blocks.
|
|
#
|
|
# A real target built by `all`, on the same terms as the tutorial games: a
|
|
# chapter whose program does not compile is the failure the documentation
|
|
# harness exists to stop.
|
|
|
|
add_executable(uidemo
|
|
uidemo.c
|
|
)
|
|
|
|
target_link_libraries(uidemo
|
|
PRIVATE akstdlib::akstdlib akerror::akerror akgl
|
|
SDL3::SDL3 SDL3_ttf::SDL3_ttf SDL3_image::SDL3_image SDL3_mixer::SDL3_mixer
|
|
jansson::jansson -lm)
|
|
target_include_directories(uidemo PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}")
|
|
target_compile_options(uidemo PRIVATE ${AKGL_WARNING_FLAGS})
|
|
|
|
# The demo needs no art -- its "world" is akgl_draw_background -- but it does
|
|
# need one font, and it uses the same test-asset face the JRPG does, compiled
|
|
# in as an absolute path for the same run-from-anywhere reason.
|
|
get_filename_component(UIDEMO_REPO_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/../.." ABSOLUTE)
|
|
target_compile_definitions(uidemo PRIVATE
|
|
UIDEMO_FONT_FILE="${UIDEMO_REPO_ROOT}/tests/assets/akgl_test_mono.ttf"
|
|
)
|
|
|
|
if(AKGL_VENDORED_DEPENDENCIES)
|
|
set_target_properties(uidemo PROPERTIES BUILD_RPATH "${AKGL_VENDORED_RPATH}")
|
|
endif()
|
|
|
|
# The headless smoke run. `--demo` tours every screen through the real event
|
|
# chain -- a mouse click on the title menu (the consumed path), keyboard into
|
|
# and out of the raw-CLAY options screen, the play screen's dialog opened and
|
|
# dismissed, and Quit confirmed from the menu -- rather than just proving that
|
|
# main() returns. There is no physics here, so nothing needs a driven clock;
|
|
# `--frames` is a backstop above the script's last step, not the exit path.
|
|
add_test(NAME example_uidemo COMMAND uidemo --frames 240 --demo)
|
|
set_tests_properties(example_uidemo PROPERTIES TIMEOUT 120)
|
|
# set_property, not set_tests_properties: the latter parses its PROPERTIES
|
|
# arguments as name/value *pairs*, so a semicolon-separated value is split and
|
|
# every element after the first is consumed as a bogus property name. See the
|
|
# same note in the other examples' CMakeLists.
|
|
set_property(TEST example_uidemo PROPERTY ENVIRONMENT
|
|
"SDL_VIDEODRIVER=dummy"
|
|
"SDL_RENDER_DRIVER=software"
|
|
"SDL_AUDIODRIVER=dummy"
|
|
)
|
|
|
|
# LD_LIBRARY_PATH for the vendored satellite libraries. Only needed when they
|
|
# were vendored; an installed build resolves them normally.
|
|
if(AKGL_VENDORED_DEPENDENCIES)
|
|
if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.22")
|
|
set(UIDEMO_TEST_ENV_MOD "")
|
|
foreach(dir IN LISTS AKGL_TEST_LIBPATH)
|
|
list(APPEND UIDEMO_TEST_ENV_MOD "LD_LIBRARY_PATH=path_list_prepend:${dir}")
|
|
endforeach()
|
|
set_property(TEST example_uidemo PROPERTY ENVIRONMENT_MODIFICATION ${UIDEMO_TEST_ENV_MOD})
|
|
else()
|
|
string(REPLACE ";" ":" UIDEMO_TEST_LIBPATH_JOINED "${AKGL_TEST_LIBPATH}")
|
|
set_property(TEST example_uidemo APPEND PROPERTY ENVIRONMENT
|
|
"LD_LIBRARY_PATH=${UIDEMO_TEST_LIBPATH_JOINED}:$ENV{LD_LIBRARY_PATH}")
|
|
endif()
|
|
endif()
|