#!/bin/sh

set -euf

cp -a tests "$AUTOPKGTEST_TMP"
cd "$AUTOPKGTEST_TMP"

DEB_HOST_ARCH=$(dpkg-architecture -qDEB_HOST_ARCH)
if [ "$DEB_HOST_ARCH" != "i386" ] && [ "$DEB_HOST_ARCH" != "armel" ] && [ "$DEB_HOST_ARCH" != "armhf" ]; then
	export MPI_OVERSUBSCRIBE="--oversubscribe"
fi
case $DEB_HOST_ARCH in
	i386)
		export DEFAULT_TIMEOUT=60
		;;
	riscv64)
		export DEFAULT_TIMEOUT=60
		;;
esac

for python in $(py3versions -s); do
	echo "== $python =="
	$python -m pytest -p pytester \
	    --cov=/usr/lib/python3/dist-packages/pytest_mpi \
	    --runpytest=subprocess \
	    tests/
done
