build: Fix testprocess invocation during "as-installed" tests

During build-time testing, we can use `$<TARGET_FILE:childprocess>` to
pass the just-built childprocess executable to it as an argument, but
during "as-installed" testing we need to use the installed path of
the childprocess executable instead.

Signed-off-by: Simon McVittie <smcv@debian.org>
This commit is contained in:
Simon McVittie 2024-09-17 18:29:38 +01:00 committed by Sam Lantinga
parent 81644d260f
commit 80da805688
2 changed files with 13 additions and 3 deletions

View File

@ -102,7 +102,7 @@ define_property(TARGET PROPERTY SDL_NONINTERACTIVE_ARGUMENTS BRIEF_DOCS "Argumen
define_property(TARGET PROPERTY SDL_NONINTERACTIVE_TIMEOUT BRIEF_DOCS "Timeout for noninteractive executable." FULL_DOCS "Timeout for noninteractive executable.") define_property(TARGET PROPERTY SDL_NONINTERACTIVE_TIMEOUT BRIEF_DOCS "Timeout for noninteractive executable." FULL_DOCS "Timeout for noninteractive executable.")
macro(add_sdl_test_executable TARGET) macro(add_sdl_test_executable TARGET)
cmake_parse_arguments(AST "BUILD_DEPENDENT;NONINTERACTIVE;NEEDS_RESOURCES;TESTUTILS;THREADS;NO_C90;MAIN_CALLBACKS;NOTRACKMEM" "" "DISABLE_THREADS_ARGS;NONINTERACTIVE_TIMEOUT;NONINTERACTIVE_ARGS;SOURCES" ${ARGN}) cmake_parse_arguments(AST "BUILD_DEPENDENT;NONINTERACTIVE;NEEDS_RESOURCES;TESTUTILS;THREADS;NO_C90;MAIN_CALLBACKS;NOTRACKMEM" "" "DISABLE_THREADS_ARGS;NONINTERACTIVE_TIMEOUT;NONINTERACTIVE_ARGS;INSTALLED_ARGS;SOURCES" ${ARGN})
if(AST_UNPARSED_ARGUMENTS) if(AST_UNPARSED_ARGUMENTS)
message(FATAL_ERROR "Unknown argument(s): ${AST_UNPARSED_ARGUMENTS}") message(FATAL_ERROR "Unknown argument(s): ${AST_UNPARSED_ARGUMENTS}")
endif() endif()
@ -139,6 +139,11 @@ macro(add_sdl_test_executable TARGET)
if(AST_NONINTERACTIVE_ARGS) if(AST_NONINTERACTIVE_ARGS)
set_property(TARGET ${TARGET} PROPERTY SDL_NONINTERACTIVE_ARGUMENTS "${AST_NONINTERACTIVE_ARGS}") set_property(TARGET ${TARGET} PROPERTY SDL_NONINTERACTIVE_ARGUMENTS "${AST_NONINTERACTIVE_ARGS}")
endif() endif()
if(AST_INSTALLED_ARGS)
set_property(TARGET ${TARGET} PROPERTY SDL_INSTALLED_ARGUMENTS "${AST_INSTALLED_ARGS}")
elseif(AST_NONINTERACTIVE_ARGS)
set_property(TARGET ${TARGET} PROPERTY SDL_INSTALLED_ARGUMENTS "${AST_NONINTERACTIVE_ARGS}")
endif()
if(AST_NONINTERACTIVE_TIMEOUT) if(AST_NONINTERACTIVE_TIMEOUT)
set_property(TARGET ${TARGET} PROPERTY SDL_NONINTERACTIVE_TIMEOUT "${AST_NONINTERACTIVE_TIMEOUT}") set_property(TARGET ${TARGET} PROPERTY SDL_NONINTERACTIVE_TIMEOUT "${AST_NONINTERACTIVE_TIMEOUT}")
endif() endif()
@ -363,7 +368,11 @@ add_sdl_test_executable(testmouse SOURCES testmouse.c)
add_sdl_test_executable(testoverlay NEEDS_RESOURCES TESTUTILS SOURCES testoverlay.c) add_sdl_test_executable(testoverlay NEEDS_RESOURCES TESTUTILS SOURCES testoverlay.c)
add_sdl_test_executable(testplatform NONINTERACTIVE SOURCES testplatform.c) add_sdl_test_executable(testplatform NONINTERACTIVE SOURCES testplatform.c)
add_sdl_test_executable(testpower NONINTERACTIVE SOURCES testpower.c) add_sdl_test_executable(testpower NONINTERACTIVE SOURCES testpower.c)
add_sdl_test_executable(testprocess NONINTERACTIVE THREADS NONINTERACTIVE_ARGS $<TARGET_FILE:childprocess> SOURCES testprocess.c) add_sdl_test_executable(testprocess
NONINTERACTIVE THREADS
NONINTERACTIVE_ARGS $<TARGET_FILE:childprocess>
INSTALLED_ARGS "${CMAKE_INSTALL_FULL_LIBEXECDIR}/installed-tests/SDL3/childprocess${CMAKE_EXECUTABLE_SUFFIX}"
SOURCES testprocess.c)
add_sdl_test_executable(childprocess SOURCES childprocess.c) add_sdl_test_executable(childprocess SOURCES childprocess.c)
add_dependencies(testprocess childprocess) add_dependencies(testprocess childprocess)
add_sdl_test_executable(testfilesystem NONINTERACTIVE SOURCES testfilesystem.c) add_sdl_test_executable(testfilesystem NONINTERACTIVE SOURCES testfilesystem.c)
@ -593,6 +602,7 @@ function(add_sdl_test TEST TARGET)
set(command ${TARGET}) set(command ${TARGET})
endif() endif()
get_property(noninteractive_arguments TARGET ${TARGET} PROPERTY SDL_NONINTERACTIVE_ARGUMENTS) get_property(noninteractive_arguments TARGET ${TARGET} PROPERTY SDL_NONINTERACTIVE_ARGUMENTS)
get_property(installed_arguments TARGET ${TARGET} PROPERTY SDL_INSTALLED_ARGUMENTS)
get_property(disable_threads_args TARGET ${TARGET} PROPERTY SDL_DISABLE_THREADS_ARGS) get_property(disable_threads_args TARGET ${TARGET} PROPERTY SDL_DISABLE_THREADS_ARGS)
get_property(uses_threads TARGET ${TARGET} PROPERTY SDL_THREADS) get_property(uses_threads TARGET ${TARGET} PROPERTY SDL_THREADS)
if(noninteractive_arguments) if(noninteractive_arguments)

View File

@ -1,3 +1,3 @@
[Test] [Test]
Type=session Type=session
Exec=@installedtestsdir@/@exe@ @noninteractive_arguments@ Exec=@installedtestsdir@/@exe@ @installed_arguments@