Skip to content

Commit

Permalink
cmake: add unittests to ctest
Browse files Browse the repository at this point in the history
  • Loading branch information
liushuyu authored and cthbleachbit committed Jun 1, 2024
1 parent 6088af4 commit cf52972
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ if (BUILD_GIMP_GPL)
set(GIMP_PALETTE_DIR ${CMAKE_INSTALL_DATADIR}/gimp/2.0/palettes CACHE STRING "Directory to place GIMP palettes")
endif()

if (BUILD_TESTS)
enable_testing()
endif()

# External
option(SYSTEM_NBTP "Use system nbtp" ON)
if (${SYSTEM_NBTP})
Expand Down
12 changes: 12 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,15 @@ foreach (PROGRAM IN LISTS PROGRAMS)
endforeach ()

add_subdirectory(tests)

if (BUILD_TESTS)
find_package(Python3 COMPONENTS Interpreter REQUIRED)
file(GLOB TEST_FIXURES LIST_DIRECTORIES false "${CMAKE_CURRENT_SOURCE_DIR}/../test-images/*.json")
foreach(TEST_FIXURE IN LISTS TEST_FIXURES)
if ("${TEST_FIXURE}" MATCHES "([^/]+)\\.json")
add_test(NAME "${CMAKE_MATCH_1}"
COMMAND "${Python3_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/../test-images/verify.py" "$<TARGET_FILE:minemap>" "${TEST_FIXURE}"
)
endif ()
endforeach()
endif ()

0 comments on commit cf52972

Please sign in to comment.