When testing the tests it can help speed things up to avoid
recreating the virtualenv, allow an env var SMB_REUSE_VENV=<path>
to supply a specific virtual env dir to (re)use.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
set -ex
-HERE=$(dirname $0)
+HERE=$(dirname "$0")
PY=${PYTHON:-python3}
-VENV=${HERE}/"_smb_tests_$$"
+if [ "${SMB_REUSE_VENV}" ]; then
+ VENV="${SMB_REUSE_VENV}"
+else
+ VENV=${HERE}/"_smb_tests_$$"
+fi
cleanup() {
+ if [ "${SMB_REUSE_VENV}" ]; then
+ return
+ fi
rm -rf "${VENV}"
}
-$PY -m venv "${VENV}"
+if ! [ -d "${VENV}" ]; then
+ $PY -m venv "${VENV}"
+fi
trap cleanup EXIT
cd "${HERE}"