# includable shell script to make test scripts smaller

set -e

echo "This script is deprecated, please use the corresponding script in the python-zope.testrunner package."

if [ ! -x /usr/bin/zope-testrunner ]; then
    echo "Could not find /usr/bin/zope-testrunner, please install python-zope.testrunner."
    exit 1
fi

if [ -z "${testfilter}" ]; then
   if [ -x /usr/bin/van-pydeb ]; then
       testfilter="-m $(van-pydeb src_to_py $(grep 'Source: ' debian/control | sed 's/Source: //'))"
   else
       echo "Could not find van-pydeb to guess the python package name. You should have your tests depend on it or you "
       echo "must specify testfilter variable, something like -s package_name, see zope-testrunner --help for details."
       exit 1
   fi
fi 
   
PYVERS=$(pyversions -r debian/control)
for python in ${PYVERS}; do
    py_libdir_sh=$(${python} -c 'from distutils import sysconfig; print(sysconfig.get_python_lib())')
    echo Running tests for ${python}: /usr/bin/zope-testrunner -k --test-path ${py_libdir_sh} ${testfilter}
    ${python} /usr/bin/zope-testrunner -k --test-path ${py_libdir_sh} ${testfilter}
done
