mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 18:22:07 +00:00
Make tests work with CTest (#1539)
Adds option to disable non-free tests
This commit is contained in:
3
.github/workflows/testing.yml
vendored
3
.github/workflows/testing.yml
vendored
@@ -33,9 +33,7 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_COMPILER=${{ matrix.cxx }} -DSANITIZERS=ON -DMORE_WARNINGS=ON
|
cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_COMPILER=${{ matrix.cxx }} -DSANITIZERS=ON -DMORE_WARNINGS=ON
|
||||||
cmake --build build -j --verbose
|
cmake --build build -j --verbose
|
||||||
cp build/src/rgb{asm,link,fix,gfx} .
|
|
||||||
sudo cmake --install build --verbose
|
sudo cmake --install build --verbose
|
||||||
cmake --install build --verbose --component "Test support programs"
|
|
||||||
- name: Package binaries
|
- name: Package binaries
|
||||||
run: |
|
run: |
|
||||||
mkdir bins
|
mkdir bins
|
||||||
@@ -175,7 +173,6 @@ jobs:
|
|||||||
cmake -S . -B build -A ${{ matrix.platform }} -DCMAKE_INSTALL_PREFIX=install_dir -DCMAKE_BUILD_TYPE=Release
|
cmake -S . -B build -A ${{ matrix.platform }} -DCMAKE_INSTALL_PREFIX=install_dir -DCMAKE_BUILD_TYPE=Release
|
||||||
cmake --build build --config Release -j --verbose
|
cmake --build build --config Release -j --verbose
|
||||||
cmake --install build --verbose --prefix install_dir
|
cmake --install build --verbose --prefix install_dir
|
||||||
cmake --install build --verbose --component "Test support programs"
|
|
||||||
- name: Package binaries
|
- name: Package binaries
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -13,4 +13,5 @@
|
|||||||
CMakeCache.txt
|
CMakeCache.txt
|
||||||
CMakeFiles/
|
CMakeFiles/
|
||||||
cmake_install.cmake
|
cmake_install.cmake
|
||||||
|
build/
|
||||||
callgrind.out.*
|
callgrind.out.*
|
||||||
|
|||||||
@@ -1,11 +1,14 @@
|
|||||||
# SPDX-License-Identifier: MIT
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
# 3.9 required for LTO checks
|
# 3.9 required for LTO checks
|
||||||
cmake_minimum_required(VERSION 3.9 FATAL_ERROR)
|
# 3.17 optional for CMAKE_CTEST_ARGUMENTS
|
||||||
|
cmake_minimum_required(VERSION 3.9..3.17 FATAL_ERROR)
|
||||||
|
|
||||||
project(rgbds
|
project(rgbds
|
||||||
LANGUAGES CXX)
|
LANGUAGES CXX)
|
||||||
|
|
||||||
|
include(CTest)
|
||||||
|
|
||||||
# get real path of source and binary directories
|
# get real path of source and binary directories
|
||||||
get_filename_component(srcdir "${CMAKE_SOURCE_DIR}" REALPATH)
|
get_filename_component(srcdir "${CMAKE_SOURCE_DIR}" REALPATH)
|
||||||
get_filename_component(bindir "${CMAKE_BINARY_DIR}" REALPATH)
|
get_filename_component(bindir "${CMAKE_BINARY_DIR}" REALPATH)
|
||||||
@@ -87,6 +90,8 @@ endif(GIT)
|
|||||||
find_package(PkgConfig)
|
find_package(PkgConfig)
|
||||||
if(MSVC OR NOT PKG_CONFIG_FOUND)
|
if(MSVC OR NOT PKG_CONFIG_FOUND)
|
||||||
# fallback to find_package
|
# fallback to find_package
|
||||||
|
# cmake's FindPNG is very fragile; it breaks when multiple versions are installed
|
||||||
|
# this is most evident on macOS but can occur on Linux too
|
||||||
find_package(PNG REQUIRED)
|
find_package(PNG REQUIRED)
|
||||||
else()
|
else()
|
||||||
pkg_check_modules(LIBPNG REQUIRED libpng)
|
pkg_check_modules(LIBPNG REQUIRED libpng)
|
||||||
@@ -98,6 +103,7 @@ set(CMAKE_CXX_STANDARD 20)
|
|||||||
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
||||||
|
|
||||||
add_subdirectory(src)
|
add_subdirectory(src)
|
||||||
|
set(CMAKE_CTEST_ARGUMENTS "--verbose")
|
||||||
add_subdirectory(test)
|
add_subdirectory(test)
|
||||||
|
|
||||||
# By default, build in Release mode; Debug mode must be explicitly requested
|
# By default, build in Release mode; Debug mode must be explicitly requested
|
||||||
|
|||||||
@@ -91,10 +91,11 @@ foreach(PROG "asm" "fix" "gfx" "link")
|
|||||||
${rgb${PROG}_src}
|
${rgb${PROG}_src}
|
||||||
${common_src}
|
${common_src}
|
||||||
)
|
)
|
||||||
if(SUFFIX)
|
|
||||||
set_target_properties(rgb${PROG} PROPERTIES SUFFIX ${SUFFIX})
|
|
||||||
endif()
|
|
||||||
install(TARGETS rgb${PROG} RUNTIME DESTINATION bin)
|
install(TARGETS rgb${PROG} RUNTIME DESTINATION bin)
|
||||||
|
# Required to run tests
|
||||||
|
set_target_properties(rgb${PROG} PROPERTIES
|
||||||
|
# hack for MSVC: no-op generator expression to stop generation of "per-configuration subdirectory"
|
||||||
|
RUNTIME_OUTPUT_DIRECTORY $<1:${CMAKE_SOURCE_DIR}>)
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
if(LIBPNG_FOUND) # pkg-config
|
if(LIBPNG_FOUND) # pkg-config
|
||||||
|
|||||||
@@ -1,13 +1,18 @@
|
|||||||
# SPDX-License-Identifier: MIT
|
# 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(randtilegen gfx/randtilegen.cpp)
|
||||||
add_executable(rgbgfx_test gfx/rgbgfx_test.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
|
configure_file(CTestCustom.cmake.in ${CMAKE_BINARY_DIR}/CTestCustom.cmake)
|
||||||
DESTINATION ${rgbds_SOURCE_DIR}/test/gfx
|
|
||||||
COMPONENT "Test support programs"
|
|
||||||
EXCLUDE_FROM_ALL
|
|
||||||
)
|
|
||||||
|
|
||||||
foreach(TARGET randtilegen rgbgfx_test)
|
foreach(TARGET randtilegen rgbgfx_test)
|
||||||
if(LIBPNG_FOUND) # pkg-config
|
if(LIBPNG_FOUND) # pkg-config
|
||||||
@@ -20,3 +25,8 @@ foreach(TARGET randtilegen rgbgfx_test)
|
|||||||
target_link_libraries(${TARGET} PRIVATE ${PNG_LIBRARIES})
|
target_link_libraries(${TARGET} PRIVATE ${PNG_LIBRARIES})
|
||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
|
add_test(NAME all
|
||||||
|
COMMAND ./run-tests.sh ${ONLY_FREE}
|
||||||
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
|
)
|
||||||
|
|||||||
1
test/CTestCustom.cmake.in
Normal file
1
test/CTestCustom.cmake.in
Normal file
@@ -0,0 +1 @@
|
|||||||
|
set(CTEST_CUSTOM_PRE_TEST "bash -c 'cd @CMAKE_CURRENT_SOURCE_DIR@\; ./fetch-test-deps.sh @ONLY_FREE@'")
|
||||||
Reference in New Issue
Block a user