Auto status change to "Under Review"
@@ -15,6 +15,10 ENDIF() | |||
|
15 | 15 | |
|
16 | 16 | INCLUDE ("cmake/sciqlop_code_coverage.cmake") |
|
17 | 17 | |
|
18 | if(BUILD_TESTS) | |
|
19 | APPEND_COVERAGE_COMPILER_FLAGS() | |
|
20 | endif(BUILD_TESTS) | |
|
21 | ||
|
18 | 22 | # |
|
19 | 23 | # Compile the diffents modules |
|
20 | 24 | # |
@@ -124,7 +124,6 if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug") | |||
|
124 | 124 | message(WARNING "Code coverage results with an optimised (non-Debug) build may be misleading") |
|
125 | 125 | endif() # NOT CMAKE_BUILD_TYPE STREQUAL "Debug" |
|
126 | 126 | |
|
127 | message( CMAKE_BUILD_TYPE : ${CMAKE_BUILD_TYPE}) | |
|
128 | 127 | if(CMAKE_COMPILER_IS_GNUCXX) |
|
129 | 128 | link_libraries(gcov) |
|
130 | 129 | else() |
@@ -144,37 +143,32 endif() | |||
|
144 | 143 | function(SETUP_TARGET_FOR_COVERAGE) |
|
145 | 144 | |
|
146 | 145 | set(options NONE) |
|
147 |
set(oneValueArgs NAME TARGET |
|
|
146 | set(oneValueArgs NAME TARGET OUTPUT) | |
|
148 | 147 | set(multiValueArgs EXECUTABLE EXECUTABLE_ARGS DEPENDENCIES) |
|
149 | 148 | cmake_parse_arguments(Coverage "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) |
|
150 | 149 | |
|
151 | 150 | if(NOT LCOV_PATH) |
|
152 |
|
|
|
151 | message(FATAL_ERROR "lcov not found! Aborting...") | |
|
153 | 152 | endif() # NOT LCOV_PATH |
|
154 | 153 | |
|
155 | 154 | if(NOT GENHTML_PATH) |
|
156 |
|
|
|
155 | message(FATAL_ERROR "genhtml not found! Aborting...") | |
|
157 | 156 | endif() # NOT GENHTML_PATH |
|
158 | message("Coverage target: " ${Coverage_TARGET}) | |
|
159 | message("Coverage name: " ${Coverage_NAME}) | |
|
160 | message("Coverage exe: " ${Coverage_EXECUTABLE}) | |
|
161 | message("Coverage gcno: " ${Coverage_GCNO}) | |
|
162 | 157 | |
|
163 | 158 | # Setup target |
|
164 | 159 | add_custom_target(${Coverage_TARGET} |
|
165 | 160 | |
|
166 | 161 | # Cleanup lcov |
|
167 |
|
|
|
162 | COMMAND ${LCOV_PATH} --directory . --zerocounters | |
|
168 | 163 | |
|
169 | 164 | # Run tests |
|
170 | 165 | COMMAND ${Coverage_EXECUTABLE} |
|
171 | # Capturing lcov counters and generating report | |
|
172 | COMMAND gcov ${Coverage_NAME} --object-file ${Coverage_GCNO} | |
|
173 | 166 | |
|
174 | # COMMAND ${LCOV_PATH} --directory . --capture --output-file ${Coverage_NAME}.info | |
|
175 |
|
|
|
176 |
|
|
|
177 |
|
|
|
167 | # Capturing lcov counters and generating report | |
|
168 | COMMAND ${LCOV_PATH} --directory . --capture --output-file ${Coverage_NAME}.info | |
|
169 | COMMAND ${LCOV_PATH} --remove ${Coverage_NAME}.info ${COVERAGE_EXCLUDES} --output-file ${Coverage_NAME}.info.cleaned | |
|
170 | COMMAND ${GENHTML_PATH} -o ${Coverage_OUTPUT} ${Coverage_NAME}.info.cleaned | |
|
171 | COMMAND ${CMAKE_COMMAND} -E remove ${Coverage_NAME}.info ${Coverage_NAME}.info.cleaned | |
|
178 | 172 | |
|
179 | 173 | WORKING_DIRECTORY ${PROJECT_BINARY_DIR} |
|
180 | 174 | DEPENDS ${Coverage_DEPENDENCIES} |
@@ -188,59 +182,7 function(SETUP_TARGET_FOR_COVERAGE) | |||
|
188 | 182 | # COMMENT "Open ./${Coverage_NAME}/index.html in your browser to view the coverage report." |
|
189 | 183 | # ) |
|
190 | 184 | |
|
191 | endfunction() # SETUP_TARGET_FOR_COVERAGE | |
|
192 | ||
|
193 | # Defines a target for running and collection code coverage information | |
|
194 | # Builds dependencies, runs the given executable and outputs reports. | |
|
195 | # NOTE! The executable should always have a ZERO as exit code otherwise | |
|
196 | # the coverage generation will not complete. | |
|
197 | # | |
|
198 | # SETUP_TARGET_FOR_COVERAGE_COBERTURA( | |
|
199 | # NAME ctest_coverage # New target name | |
|
200 | # EXECUTABLE ctest -j ${PROCESSOR_COUNT} # Executable in PROJECT_BINARY_DIR | |
|
201 | # DEPENDENCIES executable_target # Dependencies to build first | |
|
202 | # ) | |
|
203 | function(SETUP_TARGET_FOR_COVERAGE_COBERTURA) | |
|
204 | ||
|
205 | set(options NONE) | |
|
206 | set(oneValueArgs NAME) | |
|
207 | set(multiValueArgs EXECUTABLE EXECUTABLE_ARGS DEPENDENCIES) | |
|
208 | cmake_parse_arguments(Coverage "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) | |
|
209 | ||
|
210 | if(NOT SIMPLE_PYTHON_EXECUTABLE) | |
|
211 | message(FATAL_ERROR "python not found! Aborting...") | |
|
212 | endif() # NOT SIMPLE_PYTHON_EXECUTABLE | |
|
213 | ||
|
214 | if(NOT GCOVR_PATH) | |
|
215 | message(FATAL_ERROR "gcovr not found! Aborting...") | |
|
216 | endif() # NOT GCOVR_PATH | |
|
217 | ||
|
218 | # Combine excludes to several -e arguments | |
|
219 | set(COBERTURA_EXCLUDES "") | |
|
220 | foreach(EXCLUDE ${COVERAGE_EXCLUDES}) | |
|
221 | set(COBERTURA_EXCLUDES "-e ${EXCLUDE} ${COBERTURA_EXCLUDES}") | |
|
222 | endforeach() | |
|
223 | ||
|
224 | add_custom_target(${Coverage_NAME} | |
|
225 | ||
|
226 | # Run tests | |
|
227 | ${Coverage_EXECUTABLE} | |
|
228 | ||
|
229 | # Running gcovr | |
|
230 | COMMAND ${GCOVR_PATH} -x -r ${CMAKE_SOURCE_DIR} ${COBERTURA_EXCLUDES} | |
|
231 | -o ${Coverage_NAME}.xml | |
|
232 | WORKING_DIRECTORY ${PROJECT_BINARY_DIR} | |
|
233 | DEPENDS ${Coverage_DEPENDENCIES} | |
|
234 | COMMENT "Running gcovr to produce Cobertura code coverage report." | |
|
235 | ) | |
|
236 | ||
|
237 | # Show info where to find the report | |
|
238 | add_custom_command(TARGET ${Coverage_NAME} POST_BUILD | |
|
239 | COMMAND ; | |
|
240 | COMMENT "Cobertura code coverage report saved in ${Coverage_NAME}.xml." | |
|
241 | ) | |
|
242 | ||
|
243 | endfunction() # SETUP_TARGET_FOR_COVERAGE_COBERTURA | |
|
185 | endfunction() | |
|
244 | 186 | |
|
245 | 187 | function(APPEND_COVERAGE_COMPILER_FLAGS) |
|
246 | 188 | set(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS} ${COVERAGE_COMPILER_FLAGS}" PARENT_SCOPE) |
@@ -90,14 +90,9 IF(BUILD_TESTS) | |||
|
90 | 90 | |
|
91 | 91 | ADD_TEST( NAME ${testName} COMMAND ${testDirectory} ) |
|
92 | 92 | |
|
93 | set({testGCNO} ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${testName}.dir/tests/) | |
|
94 | ||
|
95 | # MESSAGE("Current build did :" ${testGCNO}) | |
|
96 | MESSAGE("Current build did :" ${CMAKE_FILES_DIRECTORY}) | |
|
97 | MESSAGE("Current build did :" ${currentTestSources}) | |
|
98 | 93 | SCIQLOP_COPY_TO_TARGET(RUNTIME ${testName} ${EXTERN_SHARED_LIBRARIES}) |
|
99 | 94 | set(Coverage_NAME ${testName}) |
|
100 | SETUP_TARGET_FOR_COVERAGE(TARGET ${testName}_coverage NAME ${testFile} EXECUTABLE ${testName}) | |
|
95 | SETUP_TARGET_FOR_COVERAGE(TARGET ${testName}_coverage OUTPUT ${testFile}-path NAME ${testFile} EXECUTABLE ${testName}) | |
|
101 | 96 | ENDFOREACH( testFile ) |
|
102 | 97 | |
|
103 | 98 | LIST(APPEND testFilesToFormat ${TESTS_SOURCES}) |
General Comments 3
Status change > Approved
You need to be logged in to leave comments.
Login now