Skip to content

Commit 785b5ec

Browse files
authored
Replace gcov & lcov with gcovr (#1867)
Use gcovr instead of gcov to support exclusion markers. This also replaces lcov, since gcov has far fewer dependencies, can be installed via uv (and looks better if anything).
1 parent 966df19 commit 785b5ec

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

opendbc/safety/tests/test.sh

+6-7
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,16 @@ pytest -n8
1919

2020
# generate and open report
2121
if [ "$1" == "--report" ]; then
22-
geninfo ./libsafety/ -o coverage.info
23-
genhtml coverage.info -o coverage-out
22+
mkdir -p tests/coverage-out
23+
gcovr -r . --html-details tests/coverage-out/index.html
2424
sensible-browser coverage-out/index.html
2525
fi
2626

2727
# test coverage
28-
GCOV_OUTPUT=$(gcov -n ./libsafety/safety.c)
29-
INCOMPLETE_COVERAGE=$(echo "$GCOV_OUTPUT" | paste -s -d' \n' | grep -E "File.*(\/safety\/safety_.*)|(safety)\.h" | grep -v "100.00%" || true)
30-
if [ -n "$INCOMPLETE_COVERAGE" ]; then
31-
echo "FAILED: Some files have less than 100% coverage:"
32-
echo "$INCOMPLETE_COVERAGE"
28+
cd ..
29+
GCOV="gcovr -r . --fail-under-line=100 -e ^board/ -e ^tests/libsafety/"
30+
if ! GCOV_OUTPUT="$($GCOV)"; then
31+
echo -e "FAILED:\n$GCOV_OUTPUT"
3332
exit 1
3433
else
3534
echo "SUCCESS: All checked files have 100% coverage!"

pyproject.toml

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ dependencies = [
2626
testing = [
2727
"cffi",
2828
"ruff",
29+
"gcovr",
2930
"pytest",
3031
"pytest-coverage",
3132
"pytest-mock",

0 commit comments

Comments
 (0)