Skip to content

Commit 9759c02

Browse files
Copilotlarp0
andcommitted
Fix coverage job: add debug output and improve error handling
Co-authored-by: larp0 <[email protected]>
1 parent d3225ff commit 9759c02

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

.github/workflows/cpp_sdk.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,17 @@ jobs:
139139
run: |
140140
cd cpp_sdk/build
141141
ninja coverage
142-
142+
143+
- name: Debug coverage files
144+
if: matrix.build-type == 'Debug' && matrix.os == 'ubuntu-latest' && matrix.compiler == 'gcc'
145+
run: |
146+
echo "Listing files in cpp_sdk/build:"
147+
ls -la cpp_sdk/build/
148+
echo "Looking for coverage files:"
149+
find cpp_sdk/build/ -name "*.info" -o -name "*.gcno" -o -name "*.gcda" | head -20
150+
143151
- name: Upload coverage to Codecov
144-
if: matrix.build-type == 'Debug' && matrix.os == 'ubuntu-latest'
152+
if: matrix.build-type == 'Debug' && matrix.os == 'ubuntu-latest' && matrix.compiler == 'gcc'
145153
uses: codecov/codecov-action@v4
146154
with:
147155
token: ${{ secrets.CODECOV_TOKEN }}

cpp_sdk/CMakeLists.txt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,16 +145,20 @@ set(GCOV_TOOL ${GCOV_EXECUTABLE})
145145
add_custom_target(coverage
146146
# Clean any existing coverage data
147147
COMMAND ${CMAKE_COMMAND} -E remove -f coverage.info coverage_filtered.info
148-
# Run tests to generate .gcda files (no need to zero counters since we clean .gcda)
148+
# Initialize coverage counters to ensure clean state
149+
COMMAND lcov --gcov-tool ${GCOV_TOOL} --zerocounters --directory . || true
150+
# Run tests to generate .gcda files
149151
COMMAND tests/aireg++_tests
150-
# Capture coverage data from all .gcno/.gcda files with error handling
151-
COMMAND lcov --gcov-tool ${GCOV_TOOL} --capture --directory . --output-file coverage.info --ignore-errors mismatch,gcov,source --rc geninfo_unexecuted_blocks=1
152+
# Capture coverage data from all .gcno/.gcda files with comprehensive error handling
153+
COMMAND lcov --gcov-tool ${GCOV_TOOL} --capture --directory . --output-file coverage.info --ignore-errors mismatch,gcov,source,unused --rc geninfo_unexecuted_blocks=1 --rc lcov_branch_coverage=0
154+
# Verify coverage.info was created
155+
COMMAND test -f coverage.info || (echo "ERROR: coverage.info not created" && exit 1)
152156
# Filter out system headers and test files
153157
COMMAND lcov --remove coverage.info '/usr/*' '*/tests/*' '*/examples/*' '*/googletest/*' --output-file coverage_filtered.info --ignore-errors mismatch,source,unused
154158
# Create output directory
155159
COMMAND ${CMAKE_COMMAND} -E make_directory coverage_html
156160
# Generate HTML report (ignore exit code since warnings can cause non-zero exit)
157-
COMMAND genhtml coverage_filtered.info --output-directory coverage_html --ignore-errors source,mismatch || true
161+
COMMAND genhtml coverage_filtered.info --output-directory coverage_html --ignore-errors source,mismatch,unused || true
158162
# Print summary
159163
COMMAND lcov --summary coverage_filtered.info
160164
DEPENDS aireg++_tests

0 commit comments

Comments
 (0)