#!/usr/bin/env bash # Runs the host tests and says how much of lib/ they run: they're built with coverage counters. # Usage: scripts/coverage.sh [out folder, default .pio/coverage] # Out: summary.json (gcovr), coverage.svg (the README's badge), index.html (line by line). # What it measures: the lines of lib/ that compile on a PC. Not lib/SD (the card's driver) and not # src/ (the Apps, the Services, everything that needs the device): those have no host tests. set -euo pipefail source "$(dirname "$0")/_docker.sh" DOCKER_EXTRA=() OUT="${1:-.pio/coverage}" run_in_container bash -c ' set -eo pipefail # a failing test fails this script, tail or not git config --global --add safe.directory "$PWD" rm -rf .pio/build/native-coverage "'"$OUT"'" mkdir -p "'"$OUT"'" pio test -e native-coverage | tail -1 gcovr -r . --filter "lib/" --object-directory .pio/build/native-coverage \ --json-summary "'"$OUT"'/summary.json" --html-details "'"$OUT"'/index.html" --print-summary | tail -4 python3 scripts/coverage_badge.py "'"$OUT"'/summary.json" "'"$OUT"'/coverage.svg" '