tests: reorganization of tests

This commit is contained in:
2025-03-30 23:12:20 +02:00
parent d607cd867a
commit 4106bcc67c
11 changed files with 3 additions and 3 deletions
+43
View File
@@ -0,0 +1,43 @@
function(addSubDirs_ofRoot anchorPath)
message("scanning: ${anchorPath}")
file(GLOB targetModules RELATIVE "${anchorPath}" "${anchorPath}/*")
foreach(module ${targetModules})
message("checking: ${module}")
get_filename_component(moduleName ${module} NAME)
set(modulePath "${anchorPath}/${moduleName}")
if (NOT IS_DIRECTORY "${modulePath}")
# skip files
continue()
endif()
if (${moduleName} MATCHES "^_.*")
# skip ignored component
continue()
endif()
if(EXISTS "${modulePath}/${DEF_UTESTDIR}")
message("Found unit-test: ${moduleName}")
add_subdirectory("${modulePath}/${DEF_UTESTDIR}" ${moduleName})
endif()
endforeach()
endfunction()
macro(unitTestsFrame)
if (CMAKE_TESTING_ENABLED)
# get_filename_component(moduleName "${CMAKE_CURRENT_LIST_DIR}/.." NAME)
file(GLOB_RECURSE targetSources "../${DEF_SRCDIR}/*.cpp" "../${DEF_SRCDIR}/*.c")
add_library(${moduleName} ${targetSources})
target_include_directories(${moduleName} PUBLIC "../${DEF_INCLUDEDIR}")
set(moduleTestName "${moduleName}Test")
file(GLOB_RECURSE testSource "*.cpp")
add_executable(${moduleTestName} ${testSource})
target_link_libraries(${moduleTestName} PRIVATE ${moduleName} doctest::doctest)
target_include_directories(${moduleTestName} PRIVATE "../${DEF_SRCDIR}")
add_test (TEST-${moduleName} ${moduleTestName})
# gtest_discover_tests(${moduleTestName}
# PROPERTIES TIMEOUT 30 LABELS ${moduleName} LABELS "all"
# )
endif()
endmacro()