proj: switching to Linux
This commit is contained in:
@@ -1,26 +1,11 @@
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
include(../../core/test/unitOnHost/test_core.cmake)
|
||||
|
||||
set(DEF_UTESTDIR "uTest")
|
||||
set(DEF_SRCDIR "src")
|
||||
set(DEF_INCLUDEDIR "include")
|
||||
|
||||
# use just host compilers for this one
|
||||
set(CMAKE_C_COMPILER "gcc")
|
||||
set(CMAKE_CXX_COMPILER "g++")
|
||||
set(CMAKE_GENERATOR "Ninja")
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE)
|
||||
set(CMAKE_VERBOSE_MAKEFILE TRUE)
|
||||
|
||||
include(test_core.cmake)
|
||||
UnitTestSetup()
|
||||
enable_testing()
|
||||
|
||||
project(UnitTests)
|
||||
|
||||
find_package(doctest REQUIRED PATHS "/mingw64/lib/cmake")
|
||||
# target_link_libraries(${PROJECT_NAME} PRIVATE doctest::doctest)
|
||||
|
||||
addSubDirs_ofRoot("${CMAKE_CURRENT_LIST_DIR}/../../components")
|
||||
|
||||
|
||||
|
||||
addSubDirs_ofRoot("${CMAKE_CURRENT_LIST_DIR}/../../core/components")
|
||||
add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/../../core/test/unitOnHost/hwMock" hwMock)
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
# Unit Testing - Software
|
||||
|
||||
In contrast to *test*-directory this module demonstrates how unit tests can also be run on host.
|
||||
These unit tests aim to test freestanding software modules with more convenient methods and tools
|
||||
|
||||
## Setup
|
||||
|
||||
make sure you have following packages installed on your host syste
|
||||
- gnu compiler
|
||||
- cmake
|
||||
- generator
|
||||
- doctest-dev
|
||||
|
||||
## Build and test code
|
||||
|
||||
* Start some terminal in *uTest*-directory that has access to all needed tools (i.e. on windows a mingw environment or WSL)
|
||||
|
||||
Run following commands
|
||||
```sh
|
||||
# run cmake configuration
|
||||
cmake -S . -B build
|
||||
# run cmake build
|
||||
cmake --build build
|
||||
# run tests
|
||||
./build/<testprog>
|
||||
# run all tests with
|
||||
cd build && ctest
|
||||
```
|
||||
@@ -1,43 +0,0 @@
|
||||
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()
|
||||
Reference in New Issue
Block a user