File tree Expand file tree Collapse file tree 2 files changed +24
-2
lines changed Expand file tree Collapse file tree 2 files changed +24
-2
lines changed Original file line number Diff line number Diff line change 3737 if : matrix.os == 'ubuntu-latest'
3838 run : sudo apt-get update && sudo apt-get install -y libsodium-dev lcov
3939
40+ - name : Install GCC-8 for code coverage
41+ if : matrix.os == 'ubuntu-latest' && matrix.compiler == 'gcc'
42+ run : sudo apt-get install -y gcc-8 g++-8
43+
44+ - name : Set GCC-8 as default for code coverage
45+ if : matrix.os == 'ubuntu-latest' && matrix.compiler == 'gcc'
46+ run : |
47+ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 80
48+ sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-8 80
49+ echo "CC=gcc-8" >> $GITHUB_ENV
50+ echo "CXX=g++-8" >> $GITHUB_ENV
51+ echo "GCOV=gcov-8" >> $GITHUB_ENV
52+
4053 - name : Install dependencies (Ubuntu)
4154 if : matrix.os == 'ubuntu-latest'
4255 run : |
@@ -133,7 +146,7 @@ jobs:
133146 ctest --verbose --output-on-failure
134147
135148 - name : Generate coverage report (Debug builds only)
136- if : matrix.build-type == 'Debug'
149+ if : matrix.build-type == 'Debug' && matrix.os == 'ubuntu-latest' && matrix.compiler == 'gcc'
137150 run : |
138151 cd cpp_sdk/build
139152 ninja coverage
Original file line number Diff line number Diff line change @@ -138,13 +138,22 @@ add_custom_target(test-integration
138138 COMMENT "Running integration tests"
139139)
140140
141+ # Check for specific gcov version for coverage
142+ find_program (GCOV_8_EXECUTABLE gcov-8)
143+ if (GCOV_8_EXECUTABLE)
144+ set (GCOV_TOOL ${GCOV_8_EXECUTABLE} )
145+ else ()
146+ find_program (GCOV_EXECUTABLE gcov)
147+ set (GCOV_TOOL ${GCOV_EXECUTABLE} )
148+ endif ()
149+
141150add_custom_target (coverage
142151 # Clean any existing coverage data
143152 COMMAND ${CMAKE_COMMAND} -E remove -f coverage.info coverage_filtered.info
144153 # Run tests to generate .gcda files (no need to zero counters since we clean .gcda)
145154 COMMAND tests/aireg++_tests
146155 # 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
156+ COMMAND lcov --gcov-tool ${GCOV_TOOL} -- capture --directory . --output -file coverage.info --ignore -errors mismatch,gcov,source --rc geninfo_unexecuted_blocks=1
148157 # Filter out system headers and test files
149158 COMMAND lcov --remove coverage.info '/usr/*' '*/tests/*' '*/examples/*' '*/googletest/*' --output -file coverage_filtered.info --ignore -errors mismatch,source ,unused
150159 # Create output directory
You can’t perform that action at this time.
0 commit comments