From 62f7963da9618c8036d79ac0e3df1b60aef01168 Mon Sep 17 00:00:00 2001 From: David Wilson Date: Tue, 2 Oct 2018 20:42:24 +0100 Subject: [PATCH] tests: make ansible/tests/ run in run_tests. --- run_tests | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/run_tests b/run_tests index 122cd79e..65bf1fef 100755 --- a/run_tests +++ b/run_tests @@ -6,15 +6,32 @@ echo '-------------------' echo set -o errexit -set -o nounset set -o pipefail UNIT2="$(which unit2)" coverage erase -coverage run "${UNIT2}" discover \ - --start-directory "tests" \ - --pattern '*_test.py' \ - "$@" + +# First run overwites coverage output. +[ "$SKIP_MITOGEN" ] || { + coverage run "${UNIT2}" discover \ + --start-directory "tests" \ + --pattern '*_test.py' \ + "$@" +} + +# Second run appends. This is since 'discover' treats subdirs as packages and +# the 'ansible' subdir shadows the real Ansible package when it contains +# __init__.py, so hack around it by just running again with 'ansible' as the +# start directory. Alternative seems to be renaming tests/ansible/ and making a +# mess of Git history. +[ "$SKIP_ANSIBLE" ] || { + export PYTHONPATH=`pwd`/tests:$PYTHONPATH + coverage run -a "${UNIT2}" discover \ + --start-directory "tests/ansible" \ + --pattern '*_test.py' \ + "$@" +} + coverage html echo coverage report is at "file://$(pwd)/htmlcov/index.html"