From eef7a71759699cfa5cd25f2006b74194d7548a82 Mon Sep 17 00:00:00 2001 From: Laurent Bachelier Date: Tue, 17 Jan 2012 19:43:51 +0100 Subject: [PATCH] Run tests with only the source modules It will use a temporary directory. It reads the WEBOOB_WORKDIR variable if you want a different backends file. It sets sources.list by itself. The temporary directory is removed if possible. It is still possible to test only one backend. --- tools/run_tests.sh | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/tools/run_tests.sh b/tools/run_tests.sh index 775e02c1..4abbdf5b 100755 --- a/tools/run_tests.sh +++ b/tools/run_tests.sh @@ -1,7 +1,28 @@ #!/bin/bash +# stop on failure +set -e +BACKEND="${1}" +[ "${WEBOOB_WORKDIR}" != "" ] || WEBOOB_WORKDIR="${HOME}/.weboob" +[ "${TMPDIR}" != "" ] || TMPDIR="/tmp" -if [ "$1" != "" ]; then - nosetests -sv $(dirname $0)/../modules/$1 +# do not allow undefined variables anymore +set -u +WEBOOB_TMPDIR=$(mktemp -d "${TMPDIR}/weboob_test.XXXXX") +cp "${WEBOOB_WORKDIR}/backends" "${WEBOOB_TMPDIR}/" + +WEBOOB_DIR=$(readlink -e $(dirname $0)/..) +echo "file://$WEBOOB_DIR/modules" > "${WEBOOB_TMPDIR}/sources.list" + +export WEBOOB_WOKDIR="${WEBOOB_TMPDIR}" + +# allow failing commands past this point +set +e +if [ "${BACKEND}" != "" ]; then + nosetests -sv "${WEBOOB_DIR}/modules/${BACKEND}" else - find $(dirname $0)/../weboob $(dirname $0)/../modules -name test.py | xargs nosetests -sv + find "${WEBOOB_DIR}/weboob" "${WEBOOB_DIR}/modules" -name test.py | xargs nosetests -sv fi + +# safe removal +rm "${WEBOOB_TMPDIR}"/{backends,sources.list} +rmdir "${WEBOOB_TMPDIR}"