projects
/
python_utils.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Log the original commandline at DEBUG level.
[python_utils.git]
/
tests
/
run_tests.sh
diff --git
a/tests/run_tests.sh
b/tests/run_tests.sh
index aa344a62ead9c57903a7aa9d09519fd2dd835700..547f87cdafccce5194dc989fe73ae59df53283d6 100755
(executable)
--- a/
tests/run_tests.sh
+++ b/
tests/run_tests.sh
@@
-7,6
+7,10
@@
DOCTEST=0
UNITTEST=0
INTEGRATION=0
FAILURES=0
UNITTEST=0
INTEGRATION=0
FAILURES=0
+TESTS_RUN=0
+COVERAGE=0
+PERF_TESTS=("string_utils_test.py")
+
dup() {
if [ $# -ne 2 ]; then
dup() {
if [ $# -ne 2 ]; then
@@
-27,7
+31,7
@@
make_header() {
local title="$1"
local title_len=${#title}
title_len=$((title_len + 4))
local title="$1"
local title_len=${#title}
title_len=$((title_len + 4))
- local width=7
6
+ local width=7
0
local left=4
local right=$(($width-($title_len+$left)))
local color="$2"
local left=4
local right=$(($width-($title_len+$left)))
local color="$2"
@@
-101,6
+105,7
@@
if [ ${DOCTEST} -eq 1 ]; then
else
OUT=$( python3 ${doctest} 2>&1 )
fi
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"
FAILED=$( echo "${OUT}" | grep '\*\*\*Test Failed\*\*\*' | wc -l )
if [ $FAILED == 0 ]; then
echo "OK"
@@
-116,10
+121,14
@@
fi
if [ ${UNITTEST} -eq 1 ]; then
for test in $(find ${ROOT} -name "*_test.py" -print); do
BASE=$(basename ${test})
if [ ${UNITTEST} -eq 1 ]; then
for test in $(find ${ROOT} -name "*_test.py" -print); do
BASE=$(basename ${test})
-
BASE
="${BASE} (unittest)"
- make_header "${
BASE
}" "${GREEN}"
+
HDR
="${BASE} (unittest)"
+ make_header "${
HDR
}" "${GREEN}"
if [ ${COVERAGE} -eq 1 ]; then
coverage run --source ${HOME}/lib --append ${test} --unittests_ignore_perf
if [ ${COVERAGE} -eq 1 ]; then
coverage run --source ${HOME}/lib --append ${test} --unittests_ignore_perf
+ if [[ " ${PERF_TESTS[*]} " =~ " ${BASE} " ]]; then
+ echo "(re-running w/o coverage to record perf results)."
+ ${test}
+ fi
else
${test}
fi
else
${test}
fi
@@
-127,14
+136,15
@@
if [ ${UNITTEST} -eq 1 ]; then
FAILURES=$((FAILURES+1))
FAILED_TESTS="${FAILED_TESTS},${BASE} (python3 ${test})"
fi
FAILURES=$((FAILURES+1))
FAILED_TESTS="${FAILED_TESTS},${BASE} (python3 ${test})"
fi
+ TESTS_RUN=$((TESTS_RUN+1))
done
fi
if [ ${INTEGRATION} -eq 1 ]; then
for test in $(find ${ROOT} -name "*_itest.py" -print); do
BASE=$(basename ${test})
done
fi
if [ ${INTEGRATION} -eq 1 ]; then
for test in $(find ${ROOT} -name "*_itest.py" -print); do
BASE=$(basename ${test})
-
BASE
="${BASE} (integration test)"
- make_header "${
BASE
}" "${ORANGE}"
+
HDR
="${BASE} (integration test)"
+ make_header "${
HDR
}" "${ORANGE}"
if [ ${COVERAGE} -eq 1 ]; then
coverage run --source ${HOME}/lib --append ${test}
else
if [ ${COVERAGE} -eq 1 ]; then
coverage run --source ${HOME}/lib --append ${test}
else
@@
-144,16
+154,22
@@
if [ ${INTEGRATION} -eq 1 ]; then
FAILURES=$((FAILURES+1))
FAILED_TESTS="${FAILED_TESTS},${BASE} (python3 ${test})"
fi
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}"
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,*_itest.py --sort=-cover
+ echo
+ echo "To recall this report w/o run-running the tests:"
+ echo
+ echo " $ coverage report --omit=config-3.8.py,*_test.py,*_itest.py --sort=-cover"
echo
echo
- echo "To reproduce this report without run-running the tests, invoke:"
+ echo "...from the 'tests' directory. Note that subsequent calls to "
+ echo "run_tests.sh with --coverage will klobber previous results. See:"
echo
echo
- echo "
$ coverage report --omit=config-3.8.py --sort=-cover
"
+ echo "
https://coverage.readthedocs.io/en/6.2/
"
echo
fi
echo
fi
@@
-161,14
+177,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
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
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
fi
echo "${FAILED_TESTS}"
echo -e "${NC}"
exit ${FAILURES}
else
- echo -e "${BLACK}${ON_GREEN}
Everything looks goo
d.${NC}"
+ echo -e "${BLACK}${ON_GREEN}
All (${TESTS_RUN}) test(s) passe
d.${NC}"
exit 0
fi
exit 0
fi