Allow independant control of coverage erase and reporting

pull/530/head
Alex Willmer 6 years ago
parent 6f17ede28b
commit e7d9ec86f9

@ -24,16 +24,22 @@ echo
# Don't use errexit, so coverage report is still generated when tests fail # Don't use errexit, so coverage report is still generated when tests fail
set -o pipefail set -o pipefail
NOCOVERAGE="${NOCOVERAGE:-}"
NOCOVERAGE_ERASE="${NOCOVERAGE_ERASE:-$NOCOVERAGE}"
NOCOVERAGE_REPORT="${NOCOVERAGE_REPORT:-$NOCOVERAGE}"
if [ ! "$UNIT2" ]; then if [ ! "$UNIT2" ]; then
UNIT2="$(which unit2)" UNIT2="$(which unit2)"
fi fi
[ "$NOCOVERAGE" ] || coverage erase if [ ! "$NOCOVERAGE_ERASE" ]; then
coverage erase
fi
# First run overwites coverage output. # First run overwites coverage output.
[ "$SKIP_MITOGEN" ] || { [ "$SKIP_MITOGEN" ] || {
if [ ! "$NOCOVERAGE" ]; then if [ ! "$NOCOVERAGE" ]; then
coverage run "${UNIT2}" discover \ coverage run -a "${UNIT2}" discover \
--start-directory "tests" \ --start-directory "tests" \
--pattern '*_test.py' \ --pattern '*_test.py' \
"$@" "$@"
@ -67,8 +73,10 @@ fi
ANSIBLE_TEST_STATUS=$? ANSIBLE_TEST_STATUS=$?
} }
[ "$NOCOVERAGE" ] || coverage html if [ ! "$NOCOVERAGE_REPORT" ]; then
[ "$NOCOVERAGE" ] || echo coverage report is at "file://$(pwd)/htmlcov/index.html" coverage html
echo "coverage report is at file://$(pwd)/htmlcov/index.html"
fi
# Exit with a non-zero status if any test run did so # Exit with a non-zero status if any test run did so
exit "$(max $MITOGEN_TEST_STATUS $ANSIBLE_TEST_STATUS)" exit "$(max $MITOGEN_TEST_STATUS $ANSIBLE_TEST_STATUS)"

Loading…
Cancel
Save