-
Notifications
You must be signed in to change notification settings - Fork 0
/
macros.cmake
45 lines (40 loc) · 1.67 KB
/
macros.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
cmake_minimum_required(VERSION 3.5)
#
# googletest and unit-tf test macros
#
macro(add_gtest NAME INCS LIBS CWD TIMEOUT)
list(APPEND TESTS "${PROJECT_SOURCE_DIR}/${NAME}")
add_executable(${NAME} ${ARGN})
target_link_libraries(${NAME} gtest gmock gtest_main ${LIBS})
gtest_discover_tests(${NAME}
WORKING_DIRECTORY ${CWD}
PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${CWD}" TIMEOUT ${TIMEOUT} ENVIRONMENT "LLVM_PROFILE_FILE=%m-%p.profraw"
NO_PRETTY_TYPES
NO_PRETTY_VALUES
)
set_target_properties(${NAME} PROPERTIES FOLDER tests)
endmacro()
macro(add_unit_test NAME INCS LIBS CWD TIMEOUT)
list(APPEND TESTS "${PROJECT_SOURCE_DIR}/${NAME}")
add_executable(${NAME} ${ARGN})
target_compile_options(${NAME} PUBLIC ${CPP_FLAGS} -DESTF_USE_RESULT_COLLECTOR -DUSE_SMART_POINTER_DEBUGGER)
target_link_libraries(${NAME} ${LIBS})
target_include_directories(${NAME} PRIVATE ${INCS})
# By default ctest eats stderr/out which makes debugging test failures inconvenient.
# To see stderr/stdout on test failure, do a:
# CTEST_OUTPUT_ON_FAILURE=1 make test
# Or add "export CTEST_OUTPUT_ON_FAILURE=1" to your .bashrc
add_test(NAME ${NAME}
COMMAND ${NAME}
WORKING_DIRECTORY ${CWD})
set_tests_properties(${NAME} PROPERTIES
TIMEOUT ${TIMEOUT}
ENVIRONMENT "LLVM_PROFILE_FILE=%m-%p.profraw"
)
endmacro()
macro(add_mocha_test NAME CWD TIMEOUT)
math(EXPR millis "${TIMEOUT} * 1000")
add_test(NAME ${NAME}
COMMAND env BUILD_TYPE=${CMAKE_BUILD_TYPE} ${MOCHA} -t ${millis} ${ARGN}
WORKING_DIRECTORY ${CWD})
endmacro()