Skip to content

Commit da8f261

Browse files
committed
Fix code coverage: Ignore line mismatch errors from Catch2 macros
Add --ignore-errors mismatch flag to lcov and genhtml commands to handle line number mismatches caused by Catch2's TEMPLATE_TEST_CASE macro expansion. This is a known issue with coverage tools and template-heavy test frameworks. Fixes: geninfo ERROR: mismatched end line for templated tests
1 parent 49fa6ee commit da8f261

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

cmake/CodeCoverage.cmake

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ function(enable_coverage target_name)
2323
add_custom_target(coverage
2424
COMMAND ${LCOV} --directory . --zerocounters
2525
COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure
26-
COMMAND ${LCOV} --directory . --capture --output-file coverage.info
27-
COMMAND ${LCOV} --remove coverage.info '/usr/*' '*/tests/*' --output-file coverage.info
28-
COMMAND ${GENHTML} coverage.info --output-directory coverage_html
26+
COMMAND ${LCOV} --directory . --capture --output-file coverage.info --ignore-errors mismatch
27+
COMMAND ${LCOV} --remove coverage.info '/usr/*' '*/tests/*' --output-file coverage.info --ignore-errors mismatch
28+
COMMAND ${GENHTML} coverage.info --output-directory coverage_html --ignore-errors mismatch
2929
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
3030
COMMENT "Generating code coverage report"
3131
)

0 commit comments

Comments
 (0)