Skip to content

Commit 6a06693

Browse files
use branch coverage
1 parent 61956f9 commit 6a06693

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

tests/CMakeLists.txt

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ function(gen_test name files compile_definitions compile_flags link_flags c_stan
5757

5858
# Apply coverage flags if coverage is enabled
5959
if (ENABLE_COVERAGE)
60-
target_compile_options(${name} PRIVATE --coverage)
61-
target_link_options(${name} PRIVATE --coverage)
60+
target_compile_options(${name} PRIVATE --coverage -fprofile-arcs -ftest-coverage)
61+
target_link_options(${name} PRIVATE --coverage -fprofile-arcs)
6262
endif()
6363

6464
set_target_properties(
@@ -105,16 +105,20 @@ if (ENABLE_COVERAGE)
105105
add_custom_target(coverage-reset
106106
COMMAND ${LCOV_PATH} --zerocounters --directory .
107107
COMMAND ${LCOV_PATH} --capture --initial --directory . --output-file coverage-base.info
108+
--rc lcov_branch_coverage=1
108109
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
109110
COMMENT "Resetting coverage counters"
110111
)
111112

112113
# Target to generate coverage report
113114
add_custom_target(coverage
114-
COMMAND ${LCOV_PATH} --capture --directory . --output-file coverage-total.info
115+
COMMAND ${LCOV_PATH} --capture --directory . --output-file coverage-total.info --rc lcov_branch_coverage=1
115116
COMMAND ${LCOV_PATH} --extract coverage-total.info '*/libudpard/udpard.c' --output-file coverage-udpard.info
116-
COMMAND ${GENHTML_PATH} coverage-udpard.info --output-directory coverage-html --title "libudpard Coverage" --legend --demangle-cpp
117+
--rc lcov_branch_coverage=1
118+
COMMAND ${GENHTML_PATH} coverage-udpard.info --output-directory coverage-html --title "libudpard coverage"
119+
--legend --demangle-cpp --branch-coverage
120+
COMMAND ${CMAKE_COMMAND} -E echo "Coverage report: file://${CMAKE_BINARY_DIR}/coverage-html/index.html"
117121
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
118-
COMMENT "Generating coverage HTML report in coverage-html/"
122+
COMMENT "Generating coverage HTML report"
119123
)
120124
endif()

0 commit comments

Comments
 (0)