Debian Codegraph @

test/CMakeLists.txt

raw
1 #
2 # %injeqt copyright begin%
3 # Copyright 2014 Rafał Malinowski ([email protected])
4 # %injeqt copyright end%
5 #
6 # This library is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU Lesser General Public
8 # License as published by the Free Software Foundation; either
9 # version 2.1 of the License, or (at your option) any later version.
10 #
11 # This library is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # Lesser General Public License for more details.
15 #
16 # You should have received a copy of the GNU Lesser General Public
17 # License along with this library; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 #
20
21 find_package (Qt5Test 5.2 REQUIRED)
22
23 option (DISABLE_COVERAGE "Do not gather coverage data" OFF)
24
25 include_directories (
26 ${CMAKE_SOURCE_DIR}/src
27 )
28
29 if (NOT DISABLE_COVERAGE)
30 set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -fprofile-arcs -ftest-coverage -O0")
31 set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -fprofile-arcs -ftest-coverage -O0")
32 set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fprofile-arcs -ftest-coverage -O0")
33
34 add_custom_target (coverage
35 COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/coverage.sh
36 WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
37 endif (NOT DISABLE_COVERAGE)
38
39 function (injeqt_add_test name file)
40 file (RELATIVE_PATH sourcePath "${CMAKE_SOURCE_DIR}/test" "${CMAKE_CURRENT_SOURCE_DIR}")
41
42 get_filename_component (exeDir "${CMAKE_CURRENT_BINARY_DIR}/${name}" PATH)
43 file (MAKE_DIRECTORY "${exeDir}")
44
45 add_executable (${name} ${file})
46 set_property (TARGET ${name} APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-error")
47 qt5_use_modules (${name} Core Test)
48
49 if (NOT DISABLE_COVERAGE)
50 target_link_libraries (${name} gcov)
51 endif (NOT DISABLE_COVERAGE)
52
53 add_test ("${sourcePath}/${name}" ${name})
54 endfunction ()
55
56 function (injeqt_add_unit_test name)
57 injeqt_add_test (${name} unit/${name}.cpp)
58 target_link_libraries (${name} injeqt)
59 endfunction ()
60
61 function (injeqt_add_integration_test name)
62 injeqt_add_test (${name} integration/${name}.cpp)
63 target_link_libraries (${name} injeqt)
64 endfunction ()
65
66 set (UNIT_TESTS
67 action-method-test
68 default-constructor-method-test
69 dependencies-test
70 dependency-test
71 factory-method-test
72 implementation-test
73 implemented-by-test
74 injector-core-test
75 injector-test
76 interfaces-utils-test
77 module-impl-test
78 module-test
79 provider-by-default-constructor-test
80 provider-by-default-constructor-configuration-test
81 provider-by-factory-test
82 provider-by-factory-configuration-test
83 provider-ready-test
84 provider-ready-configuration-test
85 required-to-satisfy-test
86 resolved-dependency-test
87 resolve-dependencies-test
88 setter-method-test
89 sorted-unique-vector-test
90 type-dependencies-test
91 type-relations-test
92 type-role-test
93 type-test
94 types-by-name-test
95 types-model-test
96 )
97
98 set (INTEGRATION_TESTS
99 default-constructor-behavior-test
100 duplicate-dependencies-test
101 factory-behavior-test
102 get-all-with-type-role-test
103 init-done-test
104 inject-into-behavior-test
105 inject-into-during-init-test
106 instantiate-all-with-type-role-test
107 ready-object-behavior-test
108 super-sub-dependency-test
109 )
110
111 foreach (UNIT_TEST ${UNIT_TESTS})
112 injeqt_add_unit_test (${UNIT_TEST})
113 endforeach ()
114
115 foreach (INTEGRATION_TEST ${INTEGRATION_TESTS})
116 injeqt_add_integration_test (${INTEGRATION_TEST})
117 endforeach ()