diff options
-rw-r--r-- | Makefile | 4 | ||||
-rwxr-xr-x | bin/invoke_pyscript_multi.bash | 35 | ||||
-rwxr-xr-x | bin/py/run_tests.py (renamed from run_tests.py) | 0 | ||||
l--------- | bin/run_tests | 1 | ||||
-rwxr-xr-x | run_tests.sh | 21 |
5 files changed, 38 insertions, 23 deletions
@@ -55,8 +55,8 @@ default: check: @true -test: ./run_tests.sh - ./run_tests.sh +test: ./bin/run_tests + ./bin/run_tests clean: rm -rf ./build/ $(BUILDDIR)/ diff --git a/bin/invoke_pyscript_multi.bash b/bin/invoke_pyscript_multi.bash new file mode 100755 index 0000000..73711cd --- /dev/null +++ b/bin/invoke_pyscript_multi.bash @@ -0,0 +1,35 @@ +#!/bin/bash +# similar to invoke_pyscript.bash, but runs the python script once for +# each python implementation (PYTHON_IMPL). +# +# Also contains some script-specific code, +# e.g. creates a R-overlay.conf.tests file. +# + +: ${PYTHON_IMPL:="python2.7 python3"} + +readonly SCRIPT=$(readlink -f "${BASH_SOURCE[0]?}") +readonly SCRIPT_NAME="${BASH_SOURCE[0]##*/}" +readonly SCRIPT_DIR="${SCRIPT%/*}" + +readonly PRJROOT="${SCRIPT_DIR%/*}" +readonly PYSCRIPT="${SCRIPT_DIR}/py/${SCRIPT_NAME%.*}.py" + +readonly CONFIG_FILE="${PRJROOT}/R-overlay.conf" + +export PYTHONPATH="${PRJROOT}${PYTHONPATH:+:}${PYTHONPATH}" + + +cd "${PRJROOT}" || exit + + +[[ -e "${CONFIG_FILE}.tests" ]] || ln -vs -- "${CONFIG_FILE}"{,.tests} || exit 2 + +for _py in ${PYTHON_IMPL}; do + if which "${_py}" 1>/dev/null 2>/dev/null; then + echo "Running ${PYSCRIPT##*/} with PYTHON=${_py}" + "${_py}" "${PYSCRIPT}" || exit + else + echo "PYTHON=${_py} not found." 1>&2 + fi +done diff --git a/run_tests.py b/bin/py/run_tests.py index b3156f1..b3156f1 100755 --- a/run_tests.py +++ b/bin/py/run_tests.py diff --git a/bin/run_tests b/bin/run_tests new file mode 120000 index 0000000..c67414a --- /dev/null +++ b/bin/run_tests @@ -0,0 +1 @@ +invoke_pyscript_multi.bash
\ No newline at end of file diff --git a/run_tests.sh b/run_tests.sh deleted file mode 100755 index 48ed757..0000000 --- a/run_tests.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh -cd "${0%/*}" || exit - -TESTPY="${PWD}/run_tests.py" -first=Y - -conf="${PWD}/R-overlay.conf" -tconf="${conf}.tests" - -[ -e "${tconf}" ] || { ln -vs -- "${conf}" "${tconf}" && first=; } || exit - -for PYTHON in python2 python3; do - if which ${PYTHON} 1>/dev/null 2>/dev/null; then - [ -n "${first}" ] && first= || echo - echo "*** Running ${TESTPY##*/} with PYTHON=${PYTHON} ***" - echo - PYTHONPATH="${PWD}" ${PYTHON} "${TESTPY}" - else - echo "PYTHON=${PYTHON} not found." 1>&2 - fi -done |