-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTestModule.cmake
80 lines (64 loc) · 1.76 KB
/
TestModule.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
include (CTest)
include (${build_environment}/flags.cmake)
include_directories (src/)
add_definitions (-DBMPTK_TARGET_test
-DBMPTK_TARGET=test
-DBMPTK_BAUDRATE=19200)
set (sources ${sources}
${unit_test_main}
src/wrap-hwlib.cpp
src/libc-stub.cpp
)
set (build_test build_test)
set (unit_test unit_test)
set (memcheck memcheck)
set (complexity_test complexity_test)
set (clangformat_test clangformat_test)
if (NOT DEFINED cyclomatic_complexity_warning)
SET(cyclomatic_complexity_warning 10)
endif (NOT DEFINED cyclomatic_complexity_warning)
if (test_build)
enable_testing ()
if (build_test_enabled)
add_test (
NAME ${build_test}
COMMAND ${CMAKE_COMMAND} --build .
)
endif (build_test_enabled)
if (unit_test_enabled)
add_executable (${unit_test} ${unit_test_main} ${sources})
add_test (
NAME ${unit_test}
COMMAND ./${unit_test}
)
set_tests_properties (
${unit_test} PROPERTIES
DEPENDS ${build_test}
)
endif (unit_test_enabled)
if (complexity_test_enabled)
add_test (
NAME ${complexity_test}
COMMAND lizard -C ${cyclomatic_complexity_warning} --warnings_only .
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
endif (complexity_test_enabled)
if (UNIX AND memcheck_enabled)
add_test (
NAME ${memcheck}
COMMAND valgrind --leak-check=full --error-exitcode=1 --errors-for-leak-kinds=definite,possible ./${unit_test}
)
set_tests_properties (
${memcheck} PROPERTIES
DEPENDS ${build_test}
)
endif (UNIX AND memcheck_enabled)
endif (test_build)
if (clang_format_test_enabled)
add_test (
NAME ${clangformat_test}
COMMAND python2 ${PROJECT_SOURCE_DIR}/.clang-format-compare.py ${PROJECT_SOURCE_DIR}/src ${PROJECT_SOURCE_DIR}/test
)
endif (clang_format_test_enabled)
# The target that is compiled for:
include (${toolchain}/targets/test/test.cmake)