• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1include_directories(${CMAKE_HOME_DIRECTORY})
2
3include(CTest)
4
5enable_testing()
6
7add_custom_target(yap_check COMMAND ${CMAKE_CTEST_COMMAND} -VV -C ${CMAKE_CFG_INTDIR})
8if (NOT TARGET check)
9    add_custom_target(check DEPENDS yap_check)
10else()
11    add_dependencies(check yap_check)
12endif()
13
14set(coverage_gcda_files)
15
16macro(add_test_executable name)
17    add_executable(${name} ${name}.cpp)
18    target_link_libraries(${name} yap)
19    target_compile_features(${name}
20        PRIVATE
21            cxx_constexpr
22            cxx_decltype_auto
23            cxx_auto_type
24            )
25    target_compile_definitions(${name} PRIVATE BOOST_NO_AUTO_PTR)
26    add_test(${name} ${CMAKE_CURRENT_BINARY_DIR}/${name})
27    if (clang_on_linux)
28        target_link_libraries(${name} c++)
29    endif ()
30    list(APPEND coverage_gcda_files ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${name}.dir/${name}.cpp.gcda)
31endmacro()
32
33add_test_executable(deref)
34add_test_executable(value)
35add_test_executable(left)
36add_test_executable(right)
37add_test_executable(print)
38add_test_executable(default_eval)
39add_test_executable(user_expression_transform_1)
40add_test_executable(user_expression_transform_2)
41add_test_executable(placeholder_eval)
42add_test_executable(call_expr)
43add_test_executable(reference_returns)
44add_test_executable(depth_stress_test_left)
45add_test_executable(depth_stress_test_right)
46add_test_executable(lazy_vector_alloc_test)
47add_test_executable(vector_alloc_test)
48add_test_executable(operators_unary)
49add_test_executable(comma)
50add_test_executable(if_else)
51add_test_executable(expression_function)
52add_test_executable(transform)
53add_test_executable(supplied_transforms)
54
55add_executable(
56    compile_tests
57    compile_tests_main.cpp
58    compile_is_expr.cpp
59    compile_const_term.cpp
60    compile_placeholders.cpp
61    compile_term_plus_expr.cpp
62    compile_term_plus_term.cpp
63    compile_term_plus_x.cpp
64    compile_x_plus_term.cpp
65    compile_term_plus_x_this_ref_overloads.cpp
66    compile_const_term.cpp
67    compile_move_only_types.cpp
68    compile_user_macros.cpp
69)
70target_link_libraries(compile_tests yap)
71if (clang_on_linux)
72    target_link_libraries(compile_tests c++)
73endif ()
74
75function(add_compile_fail_test name)
76    try_compile(
77        compiles
78        ${CMAKE_BINARY_DIR}
79        ${CMAKE_CURRENT_SOURCE_DIR}/${name}.cpp
80        COMPILE_DEFINITIONS
81            ${std_flag} -I${Boost_INCLUDE_DIRS} -I${CMAKE_SOURCE_DIR}/include
82        OUTPUT_VARIABLE foo
83    )
84    #message("foo=${foo}")
85    if (compiles)
86        message(FATAL_ERROR "Compile-fail test ${name} does not fail to compile.")
87    endif ()
88endfunction()
89
90add_compile_fail_test(fail_transform)
91add_compile_fail_test(fail_get)
92add_compile_fail_test(fail_left)
93add_compile_fail_test(fail_right)
94add_compile_fail_test(fail_cond)
95add_compile_fail_test(fail_then)
96add_compile_fail_test(fail_else)
97add_compile_fail_test(fail_callable)
98add_compile_fail_test(fail_argument)
99add_compile_fail_test(fail_make_expression)
100add_compile_fail_test(fail_make_terminal)
101
102if (BUILD_COVERAGE AND UNIX)
103    if (APPLE)
104        add_custom_target(
105            coverage
106            rm -rf ${coverage_gcda_files} lcov-all.info lcov.info output
107            COMMAND
108                ${CMAKE_CTEST_COMMAND} -VV -C ${CMAKE_CFG_INTDIR}
109            COMMAND
110                cd ${CMAKE_BINARY_DIR}
111            COMMAND
112                llvm-cov gcov -f -b ${coverage_gcda_files}
113            COMMAND
114                lcov --directory . --base-directory . --gcov-tool ${CMAKE_SOURCE_DIR}/llvm-gcov.sh --capture -o lcov-all.info
115            COMMAND
116                lcov -e lcov-all.info ${CMAKE_SOURCE_DIR}/include/boost/yap/* ${CMAKE_SOURCE_DIR}/include/boost/yap/detail/* -o lcov.info
117            COMMAND
118                genhtml lcov.info -o output
119        )
120    else ()
121        add_custom_target(
122            coverage
123            rm -rf ${coverage_gcda_files} lcov-all.info lcov.info output
124            COMMAND
125                ${CMAKE_CTEST_COMMAND} -j4 -VV -C ${CMAKE_CFG_INTDIR}
126            COMMAND
127                cd ${CMAKE_BINARY_DIR}
128            COMMAND
129                gcov -f -b ${coverage_gcda_files}
130            COMMAND
131                lcov --directory . --base-directory . --capture -o lcov-all.info
132            COMMAND
133                lcov -e lcov-all.info ${CMAKE_SOURCE_DIR}/include/boost/yap/* ${CMAKE_SOURCE_DIR}/include/boost/yap/detail/* -o lcov.info
134            COMMAND
135                genhtml lcov.info -o output
136        )
137    endif ()
138endif ()
139