@@ -47,26 +47,46 @@ jobs:
4747 - name : Collect coverage data (version-aware)
4848 run : |
4949 # Check lcov version and use appropriate flags
50- LCOV_VERSION=$(lcov --version 2>&1 | grep -oP 'lcov version \K[0-9]+\.[0-9]+' || echo "0 .0")
50+ LCOV_VERSION=$(lcov --version 2>&1 | head -n1 | grep -oP 'version \K[0-9]+\.[0-9]+' || echo "1 .0")
5151 echo "Detected lcov version: $LCOV_VERSION"
5252
53- # lcov 2.0+ supports geninfo_unexecuted_blocks, older versions (1.x) do not
54- if [ "$(printf '%s\n' "2.0" "$LCOV_VERSION" | sort -V | head -n1)" = "2.0" ]; then
55- echo "Using lcov 2.0+ flags with geninfo_unexecuted_blocks"
53+ # Parse major and minor version
54+ MAJOR_VERSION=$(echo $LCOV_VERSION | cut -d. -f1)
55+ MINOR_VERSION=$(echo $LCOV_VERSION | cut -d. -f2)
56+ echo "Major version: $MAJOR_VERSION, Minor version: $MINOR_VERSION"
57+
58+ # Determine which flags to use based on version
59+ if [ "$MAJOR_VERSION" -ge 2 ]; then
60+ echo "Using lcov 2.0+ configuration"
61+ # lcov 2.0+ supports geninfo_unexecuted_blocks and enhanced ignore-errors
5662 /usr/bin/lcov --directory ./build --capture --output-file ./build/coverage.info \
5763 --rc geninfo_unexecuted_blocks=1 --ignore-errors mismatch,negative,unused
58- else
59- echo "Using lcov 1.x flags (geninfo_unexecuted_blocks not supported)"
64+ elif [ "$MAJOR_VERSION" -eq 1 ] && [ "$MINOR_VERSION" -ge 14 ]; then
65+ echo "Using lcov 1.14+ configuration"
66+ # lcov 1.14+ supports --ignore-errors but only with 'unused' flag
6067 /usr/bin/lcov --directory ./build --capture --output-file ./build/coverage.info \
61- --ignore-errors mismatch,negative,unused
68+ --ignore-errors unused
69+ else
70+ echo "Using lcov 1.13 or older configuration"
71+ # Older versions don't support --ignore-errors at all
72+ /usr/bin/lcov --directory ./build --capture --output-file ./build/coverage.info || true
6273 fi
6374
64- # Filter coverage data (same for all versions)
65- /usr/bin/lcov --ignore-errors unused -remove ./build/coverage.info \
66- "/usr/*" \
67- "*/tests/*" \
68- "*/src/demo/*" \
69- --output-file ./build/coverage.info
75+ # Filter coverage data
76+ echo "Filtering coverage data..."
77+ if [ "$MAJOR_VERSION" -ge 1 ] && [ "$MINOR_VERSION" -ge 14 ]; then
78+ /usr/bin/lcov --ignore-errors unused -remove ./build/coverage.info \
79+ "/usr/*" \
80+ "*/tests/*" \
81+ "*/src/demo/*" \
82+ --output-file ./build/coverage.info
83+ else
84+ /usr/bin/lcov -remove ./build/coverage.info \
85+ "/usr/*" \
86+ "*/tests/*" \
87+ "*/src/demo/*" \
88+ --output-file ./build/coverage.info || true
89+ fi
7090 - name : Show coverage summary
7191 run : /usr/bin/lcov --list ./build/coverage.info
7292 - uses : codecov/codecov-action@v4
0 commit comments