Harmonise naming of CMake test knobs

Also reorganise the file a little
This commit is contained in:
ISSOtm
2026-03-14 22:31:11 -04:00
committed by Rangi
parent c963c7b1c7
commit 45fff0fd58
4 changed files with 23 additions and 23 deletions

View File

@@ -383,7 +383,7 @@ jobs:
prepare: |
.github/scripts/install_deps.sh freebsd
run: | # FreeBSD `c++` compiler does not support `make develop` sanitizers ASan or UBSan
cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_COMPILER=c++ -DUSE_EXTERNAL_TESTS=OFF -DTESTS_OS_NAME=freebsd
cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_COMPILER=c++ -DTESTS_RUN_EXTERNAL=OFF -DTESTS_OS_NAME=freebsd
cmake --build build -j4 --verbose
cmake --install build --verbose
cmake --build build --target test

View File

@@ -8,7 +8,7 @@ project(rgbds
DESCRIPTION "Game Boy assembly toolchain"
HOMEPAGE_URL "https://rgbds.gbdev.io")
include(CTest) # Note: must be in the top-level dir.
include(CTest) # Note: CTest only functions properly if included from the top-level CMakeLists.
include(GNUInstallDirs)
# Reject in-source builds, as they may conflict with the Makefile.

View File

@@ -1,23 +1,8 @@
# SPDX-License-Identifier: MIT
option(USE_NONFREE_TESTS "run tests that build nonfree codebases" ON)
option(USE_EXTERNAL_TESTS "run tests that build external codebases" ON)
set(TESTS_OS_NAME "" CACHE STRING "skip running tests known to fail on this OS")
set(ONLY_FREE)
if(NOT USE_NONFREE_TESTS)
set(ONLY_FREE "--only-free")
endif()
set(ONLY_INTERNAL)
if(NOT USE_EXTERNAL_TESTS)
set(ONLY_INTERNAL "--only-internal")
endif()
set(OS_NAME)
if(NOT TESTS_OS_NAME STREQUAL "")
set(OS_NAME "--os" "${TESTS_OS_NAME}")
endif()
option(TESTS_RUN_NONFREE "Run tests that build nonfree codebases." ON)
option(TESTS_RUN_EXTERNAL "Run tests that build external codebases." ON)
set(TESTS_OS_NAME "" CACHE STRING "Skip running tests known to fail on this OS.")
add_executable(randtilegen gfx/randtilegen.cpp)
add_executable(rgbgfx_test gfx/rgbgfx_test.cpp)
@@ -25,8 +10,6 @@ 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>)
configure_file(CTestCustom.cmake.in ${CMAKE_BINARY_DIR}/CTestCustom.cmake)
foreach(TARGET randtilegen rgbgfx_test)
if(LIBPNG_FOUND) # pkg-config
target_include_directories(${TARGET} PRIVATE ${LIBPNG_INCLUDE_DIRS})
@@ -39,6 +22,23 @@ foreach(TARGET randtilegen rgbgfx_test)
endif()
endforeach()
set(ONLY_FREE)
if(NOT TESTS_RUN_NONFREE)
set(ONLY_FREE "--only-free")
endif()
set(ONLY_INTERNAL)
if(NOT TESTS_RUN_EXTERNAL)
set(ONLY_INTERNAL "--only-internal")
endif()
set(OS_NAME)
if(NOT TESTS_OS_NAME STREQUAL "")
set(OS_NAME "--os" "${TESTS_OS_NAME}")
endif()
configure_file(CTestCustom.cmake.in ${CMAKE_BINARY_DIR}/CTestCustom.cmake @ONLY)
add_test(NAME all
COMMAND ./run-tests.sh ${ONLY_FREE} ${ONLY_INTERNAL} ${OS_NAME}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}

View File

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