Skip to content

Commit 609fef2

Browse files
committed
Fix the lcov issue with ggtest
1 parent 4d72c0f commit 609fef2

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

.github/workflows/cpp-build-test-coverage.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ jobs:
6464
rm -rf build
6565
mkdir build
6666
cd build
67-
cmake ..
67+
cmake -DCMAKE_BUILD_TYPE=Debug -DENABLE_COVERAGE=ON ..
6868
cmake --build .
6969
7070
# -------------------------------------------------------
@@ -82,8 +82,8 @@ jobs:
8282
# -------------------------------------------------------
8383
- name: Generate coverage report
8484
run: |
85-
lcov -d . -c -o coverage.info
86-
lcov -r coverage.info "*/build/*" "*/tests/*" "*/c++/*" -o coverageFiltered.info
85+
lcov --rc geninfo_unexecuted_blocks=1 --ignore-errors mismatch -d . -c -o coverage.info
86+
lcov -r coverage.info "*/_deps/*" "/usr/*" "*/tests/*" -o coverageFiltered.info
8787
lcov --list coverageFiltered.info
8888
8989
# -------------------------------------------------------

CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,16 @@ message("C++ Compiler: ${CMAKE_CXX_COMPILER}")
2626
message("C++ Compiler ID: ${CMAKE_CXX_COMPILER_ID}")
2727
message("C++ Compiler Version: ${CMAKE_CXX_COMPILER_VERSION}")
2828

29+
# Option to enable coverage
30+
option(ENABLE_COVERAGE "Enable coverage reporting" OFF)
31+
32+
if(ENABLE_COVERAGE AND CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
33+
message(STATUS "Enabling coverage flags")
34+
add_compile_options(--coverage -O0 -g)
35+
add_link_options(--coverage)
36+
endif()
37+
38+
2939
# ----------------------------------------------------------------------------------------
3040
# Dependencies - GoogleTest
3141
# ----------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)