#!/bin/bash
set -e

# limit thread parallelisation to no more than 4 cpus
# but respect any existing value of QUTIP_NUM_PROCESSES
ncpu=${QUTIP_NUM_PROCESSES}
if [ "x${ncpu}" = "x" ]; then
    ncpu=$(nproc)
    ncpu=$(( ncpu > 4 ? 4 : ncpu ))
fi
export QUTIP_NUM_PROCESSES=${ncpu}

cp -r qutip/tests "$AUTOPKGTEST_TMP"
cd "$AUTOPKGTEST_TMP"

# if we need to report issues upstream, they will want to know the environment
echo "Your Environment: qutip.about()"
python3 -c "import qutip; qutip.about()"
echo "==============================="

for py in $(py3versions -s 2>/dev/null); do
    echo "Testing with $py:"
    $py -mpytest tests -k "not test_simdiag"
done
