File tree Expand file tree Collapse file tree 2 files changed +15
-9
lines changed Expand file tree Collapse file tree 2 files changed +15
-9
lines changed Original file line number Diff line number Diff line change @@ -139,9 +139,21 @@ add_custom_target(test-integration
139139)
140140
141141add_custom_target (coverage
142- COMMAND gcov -r *.gcno
143- COMMAND lcov --capture --directory . --output -file coverage.info
144- COMMAND genhtml coverage.info --output -directory coverage_html
142+ # Clean any existing coverage data
143+ COMMAND ${CMAKE_COMMAND} -E remove -f coverage.info coverage_filtered.info
144+ # Run tests to generate .gcda files (no need to zero counters since we clean .gcda)
145+ COMMAND tests/aireg++_tests
146+ # Capture coverage data from all .gcno/.gcda files with error handling
147+ COMMAND lcov --capture --directory . --output -file coverage.info --ignore -errors mismatch,gcov,source --rc geninfo_unexecuted_blocks=1
148+ # Filter out system headers and test files
149+ COMMAND lcov --remove coverage.info '/usr/*' '*/tests/*' '*/examples/*' '*/googletest/*' --output -file coverage_filtered.info --ignore -errors mismatch,source ,unused
150+ # Create output directory
151+ COMMAND ${CMAKE_COMMAND} -E make_directory coverage_html
152+ # Generate HTML report (ignore exit code since warnings can cause non-zero exit)
153+ COMMAND genhtml coverage_filtered.info --output -directory coverage_html --ignore -errors source ,mismatch || true
154+ # Print summary
155+ COMMAND lcov --summary coverage_filtered.info
156+ DEPENDS aireg++_tests
145157 COMMENT "Generating coverage report"
146158)
147159
Original file line number Diff line number Diff line change @@ -4,12 +4,6 @@ cmake_minimum_required(VERSION 3.16)
44find_package (GTest REQUIRED)
55include (GoogleTest)
66
7- # Enable coverage if in Debug mode
8- if (CMAKE_BUILD_TYPE STREQUAL "Debug" )
9- set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage" )
10- set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage" )
11- endif ()
12-
137# Create test executable
148add_executable (aireg++_tests
159 test_main.cpp
You can’t perform that action at this time.
0 commit comments