From e7d9ec86f99c1f6f37bd9e70b52578616751f7cf Mon Sep 17 00:00:00 2001 From: Alex Willmer Date: Sat, 9 Feb 2019 19:49:01 +0000 Subject: [PATCH] Allow independant control of coverage erase and reporting --- run_tests | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/run_tests b/run_tests index 2877ec65..b583af3b 100755 --- a/run_tests +++ b/run_tests @@ -24,16 +24,22 @@ echo # Don't use errexit, so coverage report is still generated when tests fail set -o pipefail +NOCOVERAGE="${NOCOVERAGE:-}" +NOCOVERAGE_ERASE="${NOCOVERAGE_ERASE:-$NOCOVERAGE}" +NOCOVERAGE_REPORT="${NOCOVERAGE_REPORT:-$NOCOVERAGE}" + if [ ! "$UNIT2" ]; then UNIT2="$(which unit2)" fi -[ "$NOCOVERAGE" ] || coverage erase +if [ ! "$NOCOVERAGE_ERASE" ]; then + coverage erase +fi # First run overwites coverage output. [ "$SKIP_MITOGEN" ] || { if [ ! "$NOCOVERAGE" ]; then - coverage run "${UNIT2}" discover \ + coverage run -a "${UNIT2}" discover \ --start-directory "tests" \ --pattern '*_test.py' \ "$@" @@ -67,8 +73,10 @@ fi ANSIBLE_TEST_STATUS=$? } -[ "$NOCOVERAGE" ] || coverage html -[ "$NOCOVERAGE" ] || echo coverage report is at "file://$(pwd)/htmlcov/index.html" +if [ ! "$NOCOVERAGE_REPORT" ]; then + 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 "$(max $MITOGEN_TEST_STATUS $ANSIBLE_TEST_STATUS)"