Skip to content

Commit db7ce2a

Browse files
authored
CICD: Fix for lcov choking Pybind11 init (#138)
* CICD: Fix for lcov choking Pybind11 init * Remove third party from exclude pattern as it's empty
1 parent a5324de commit db7ce2a

1 file changed

Lines changed: 27 additions & 23 deletions

File tree

cmake/CoverageTarget.cmake

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,40 +7,44 @@ IF (ENABLE_COVERAGE)
77
MESSAGE(FATAL_ERROR "lcov not found, cannot perform coverage.")
88
ENDIF ()
99

10-
# coveralls.io does not support striped paths
11-
#find_program (SED NAMES sed)
12-
#if (NOT SED)
13-
# message(FATAL_ERROR "Unable to find sed")
14-
#else()
15-
# # message(STATUS "sed found at ${SED}")
16-
#endif (NOT SED)
17-
18-
# Don't forget '' around each pattern
19-
SET(LCOV_EXCLUDE_PATTERN "'${PROJECT_SOURCE_DIR}/third_party/*'" "'${PROJECT_SOURCE_DIR}/extern/*'")
10+
SET(LCOV_EXCLUDE_PATTERN
11+
"'${PROJECT_SOURCE_DIR}/extern/*'"
12+
"'${PROJECT_SOURCE_DIR}/tests/src/bindings.cpp'"
13+
)
2014

2115
ADD_CUSTOM_TARGET(coverage
22-
# Cleanup previously generated profiling data
2316
COMMAND ${LCOV} --base-directory ${PROJECT_SOURCE_DIR} --directory ${PROJECT_BINARY_DIR} --zerocounters
24-
# Initialize profiling data with zero coverage for every instrumented line of the project
25-
# This way the percentage of total lines covered will always be correct, even when not all source code files were loaded during the test(s)
26-
COMMAND ${LCOV} --base-directory ${PROJECT_SOURCE_DIR} --directory ${PROJECT_BINARY_DIR} --capture --initial --output-file coverage_base.info
27-
# Run tests
17+
18+
# Initial capture
19+
COMMAND ${LCOV} --base-directory ${PROJECT_SOURCE_DIR}
20+
--directory ${PROJECT_BINARY_DIR}
21+
--capture
22+
--initial
23+
--ignore-errors mismatch
24+
--output-file coverage_base.info
25+
2826
COMMAND ${CMAKE_CTEST_COMMAND} -j ${PROCESSOR_COUNT}
29-
# Collect data from executions
30-
COMMAND ${LCOV} --base-directory ${PROJECT_SOURCE_DIR} --directory ${PROJECT_BINARY_DIR} --capture --output-file coverage_ctest.info
31-
# Combine base and ctest results
32-
COMMAND ${LCOV} --add-tracefile coverage_base.info --add-tracefile coverage_ctest.info --output-file coverage_full.info
33-
# Extract only project data (--no-capture or --remove options may be used to select collected data)
27+
28+
# Post-test capture
29+
COMMAND ${LCOV} --base-directory ${PROJECT_SOURCE_DIR}
30+
--directory ${PROJECT_BINARY_DIR}
31+
--capture
32+
--ignore-errors mismatch
33+
--output-file coverage_ctest.info
34+
35+
COMMAND ${LCOV} --add-tracefile coverage_base.info
36+
--add-tracefile coverage_ctest.info
37+
--output-file coverage_full.info
38+
3439
COMMAND ${LCOV} --remove coverage_full.info ${LCOV_EXCLUDE_PATTERN} --output-file coverage_filtered.info
3540
COMMAND ${LCOV} --extract coverage_filtered.info '${PROJECT_SOURCE_DIR}/*' --output-file coverage.info
36-
# coveralls.io does not support striped paths
37-
#COMMAND ${SED} -i.bak 's|SF:${PROJECT_SOURCE_DIR}/|SF:|g' coverage.info
41+
3842
DEPENDS tests
3943
COMMENT "Running test coverage."
4044
WORKING_DIRECTORY "${PROJECT_BINARY_DIR}"
4145
)
4246
MESSAGE(STATUS "coverage target for code coverage is available")
43-
47+
4448
FIND_PROGRAM(GENHTML genhtml)
4549
IF (NOT GENHTML)
4650
MESSAGE(WARNING "genhtml not found, cannot perform report-coverage.")

0 commit comments

Comments
 (0)