X-Git-Url: https://wannabe.guru.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=tests%2Frun_tests.sh;h=8af47490d372a07ea334804aa5f7a22b009ec58e;hb=822454f580c1ff9eb207b8da46cdfae24e30cde1;hp=aa344a62ead9c57903a7aa9d09519fd2dd835700;hpb=67e324d8995c18445574415eb44abcfdce436bdc;p=python_utils.git diff --git a/tests/run_tests.sh b/tests/run_tests.sh index aa344a6..8af4749 100755 --- a/tests/run_tests.sh +++ b/tests/run_tests.sh @@ -7,6 +7,8 @@ DOCTEST=0 UNITTEST=0 INTEGRATION=0 FAILURES=0 +TESTS_RUN=0 +COVERAGE=0 dup() { if [ $# -ne 2 ]; then @@ -27,7 +29,7 @@ make_header() { local title="$1" local title_len=${#title} title_len=$((title_len + 4)) - local width=76 + local width=70 local left=4 local right=$(($width-($title_len+$left))) local color="$2" @@ -101,6 +103,7 @@ if [ ${DOCTEST} -eq 1 ]; then else OUT=$( python3 ${doctest} 2>&1 ) fi + TESTS_RUN=$((TESTS_RUN+1)) FAILED=$( echo "${OUT}" | grep '\*\*\*Test Failed\*\*\*' | wc -l ) if [ $FAILED == 0 ]; then echo "OK" @@ -127,6 +130,7 @@ if [ ${UNITTEST} -eq 1 ]; then FAILURES=$((FAILURES+1)) FAILED_TESTS="${FAILED_TESTS},${BASE} (python3 ${test})" fi + TESTS_RUN=$((TESTS_RUN+1)) done fi @@ -144,16 +148,22 @@ if [ ${INTEGRATION} -eq 1 ]; then FAILURES=$((FAILURES+1)) FAILED_TESTS="${FAILED_TESTS},${BASE} (python3 ${test})" fi + TESTS_RUN=$((TESTS_RUN+1)) done fi if [ ${COVERAGE} -eq 1 ]; then make_header "Code Coverage Report" "${GREEN}" - coverage report --omit=config-3.8.py --sort=-cover + coverage report --omit=config-3.8.py,*_test.py --sort=-cover echo - echo "To reproduce this report without run-running the tests, invoke:" + echo "To recall this report w/o run-running the tests:" echo - echo " $ coverage report --omit=config-3.8.py --sort=-cover" + echo " $ coverage report --omit=config-3.8.py,*_test.py --sort=-cover" + echo + echo "...from the 'tests' directory. Note that subsequent calls to " + echo "run_tests.sh with --coverage will klobber previous results. See:" + echo + echo " https://coverage.readthedocs.io/en/6.2/" echo fi @@ -161,14 +171,14 @@ if [ ${FAILURES} -ne 0 ]; then FAILED_TESTS=$(echo ${FAILED_TESTS} | sed 's/^,/__/g') FAILED_TESTS=$(echo ${FAILED_TESTS} | sed 's/,/\n__/g') if [ ${FAILURES} -eq 1 ]; then - echo -e "${RED}There was ${FAILURES} failure:" + echo -e "${RED}There was ${FAILURES}/${TESTS_RUN} failure:" else - echo -e "${RED}There were ${FAILURES} failures:" + echo -e "${RED}There were ${FAILURES}/${TESTS_RUN} failures:" fi echo "${FAILED_TESTS}" echo -e "${NC}" exit ${FAILURES} else - echo -e "${BLACK}${ON_GREEN}Everything looks good.${NC}" + echo -e "${BLACK}${ON_GREEN}All (${TESTS_RUN}) test(s) passed.${NC}" exit 0 fi