Files
anki/tools/coverage/coverage-py
Christos Longros 2d88e386dc build: portability fixes for FreeBSD (#5300)
Two build fixes found while getting the build working on FreeBSD. 

1. **Remove hardcoded `#!/bin/bash` paths and use /usr/bin/env instead
/**
2. **env_remove("YARN_BINARY")**

Tested on FreeBSD 16.0-CURRENT amd64.

A second series adds FreeBSD support with `platform` variants,
environment overrides, PyQt6 handling and docs.

Closes #5301
2026-08-11 13:13:56 +03:00

43 lines
1.1 KiB
Bash
Executable File

#!/usr/bin/env bash
set -e
target="$1"
html="$2"
case "$target" in
pylib)
pythonpath="out/pylib"
source="pylib/anki"
outdir="out/coverage/python-pylib"
tests="pylib/tests"
threshold=63
;;
qt)
pythonpath="pylib:out/pylib:out/qt:qt/tools"
source="qt/aqt,qt/tools"
outdir="out/coverage/python-qt"
tests="qt/tests"
threshold=20
;;
*)
echo "Usage: $0 [pylib|qt] [--html]"
exit 1
;;
esac
mkdir -p "$outdir"
PYTHONPATH="$pythonpath" ANKI_TEST_MODE=1 out/pyenv/bin/python -m coverage run \
--source="$source" --data-file="$outdir/.coverage" \
-m pytest -p no:cacheprovider "$tests"
out/pyenv/bin/python -m coverage json \
--data-file="$outdir/.coverage" -o "$outdir/coverage-summary.json"
out/pyenv/bin/python -m coverage report \
--data-file="$outdir/.coverage" --fail-under="$threshold"
if [ "$html" = "--html" ]; then
out/pyenv/bin/python -m coverage html \
--data-file="$outdir/.coverage" -d "$outdir/html" --fail-under="$threshold"
echo "Python $target coverage report: $outdir/html/index.html"
fi