Make tests work with CTest (#1539)

Adds option to disable non-free tests
This commit is contained in:
JL2210
2024-10-15 19:26:17 -04:00
committed by GitHub
parent a2ff653a83
commit e623aeb85d
6 changed files with 28 additions and 12 deletions

View File

@@ -1,13 +1,18 @@
# SPDX-License-Identifier: MIT
OPTION(USE_NONFREE_TESTS "run tests that build nonfree codebases" ON)
if(NOT USE_NONFREE_TESTS)
set(ONLY_FREE "--only-free")
endif()
add_executable(randtilegen gfx/randtilegen.cpp)
add_executable(rgbgfx_test gfx/rgbgfx_test.cpp)
set_target_properties(randtilegen rgbgfx_test PROPERTIES
# hack for MSVC: no-op generator expression to stop generation of "per-configuration subdirectory"
RUNTIME_OUTPUT_DIRECTORY $<1:${CMAKE_CURRENT_SOURCE_DIR}/gfx>)
install(TARGETS randtilegen rgbgfx_test
DESTINATION ${rgbds_SOURCE_DIR}/test/gfx
COMPONENT "Test support programs"
EXCLUDE_FROM_ALL
)
configure_file(CTestCustom.cmake.in ${CMAKE_BINARY_DIR}/CTestCustom.cmake)
foreach(TARGET randtilegen rgbgfx_test)
if(LIBPNG_FOUND) # pkg-config
@@ -20,3 +25,8 @@ foreach(TARGET randtilegen rgbgfx_test)
target_link_libraries(${TARGET} PRIVATE ${PNG_LIBRARIES})
endif()
endforeach()
add_test(NAME all
COMMAND ./run-tests.sh ${ONLY_FREE}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)

View File

@@ -0,0 +1 @@
set(CTEST_CUSTOM_PRE_TEST "bash -c 'cd @CMAKE_CURRENT_SOURCE_DIR@\; ./fetch-test-deps.sh @ONLY_FREE@'")