kick/coverage.sh

27 lines
1.1 KiB
Bash
Executable file

#!/bin/sh
# Line coverage of kick.c unioned across the test suite (gcc/gcov route).
#
# ./coverage.sh [pytest args...] # e.g. ./coverage.sh tests/test_smoke.py::test_cycle_tabs
# # with no args: full default suite
#
# Builds build-cov/ instrumented (--coverage + KICK_COVERAGE flush hook for
# the SIGTERM/_exit teardown path), zeroes counters, runs pytest against
# build-cov/kick via KICK_BIN, then reports kick.c line coverage (gcda
# counters merge automatically across the many kick invocations).
set -e
cd "$(dirname "$0")"
if [ ! -f build-cov/build.ninja ]; then
meson setup build-cov -Db_coverage=true "-Dc_args=-DKICK_COVERAGE"
else
meson setup build-cov --reconfigure -Db_coverage=true "-Dc_args=-DKICK_COVERAGE"
fi
meson compile -C build-cov kick wltest
find build-cov -name '*.gcda' -delete
KICK_BIN="$PWD/build-cov/kick" pytest "$@"
echo "--- kick.c line coverage (union of all runs above) ---"
gcovr -r . --filter 'kick\.c$' --txt
gcovr -r . --filter 'kick\.c$' --html-details -o build-cov/cov-kick.html
echo "HTML: build-cov/cov-kick.html"