1
0
mirror of https://github.com/github/octodns.git synced 2024-05-11 05:55:00 +00:00

Use pytest's built in coverage support

This commit is contained in:
Ross McFarland
2022-01-14 10:09:34 -08:00
parent 3ed6d743e6
commit 7efd4f8b2f
2 changed files with 17 additions and 11 deletions

2
.coveragerc Normal file
View File

@@ -0,0 +1,2 @@
[run]
omit = octodns/cmds/*

View File

@@ -30,19 +30,23 @@ export ARM_CLIENT_SECRET=
export ARM_TENANT_ID=
export ARM_SUBSCRIPTION_ID=
SOURCE_DIR="octodns/"
# Don't allow disabling coverage
grep -r -I --line-number "# pragma: +no.*cover" octodns && {
echo "Code coverage should not be disabled"
exit 1
grep -r -I --line-number "# pragma: +no.*cover" $SOURCE_DIR && {
echo "Code coverage should not be disabled"
exit 1
}
export PYTHONPATH=.:$PYTHONPATH
coverage run --branch --source=octodns --omit=octodns/cmds/* "$(command -v pytest)" --disable-network "$@"
coverage html
coverage xml
coverage report --show-missing
coverage report | grep ^TOTAL | grep -qv 100% && {
echo "Incomplete code coverage" >&2
exit 1
} || echo "Code coverage 100%"
pytest \
--disable-network \
--cov-reset \
--cov=$SOURCE_DIR \
--cov-fail-under=100 \
--cov-report=html \
--cov-report=xml \
--cov-report=term \
--cov-branch \
"$@"