#!/bin/sh
# autopkgtest check based on upstream Makefile check-doctest
set -ue

testname="$1"
flavour="$2"
test -n "$testname"

# This is a bit hacky and not ideal; unfortunately autopkgtest is primitive and
# will cause an error if we hard-depend on python-cysignals-pari in
# d/tests/control but then don't actually build it.
if [ "$flavour" = "pari" ] && ! dpkg -s python-cysignals-pari >/dev/null 2>/dev/null; then
	echo "********************************************************************************"
	echo "skipping test: python-cysignals-pari not installed, did you build it?"
	echo "to build it, use \`dpkg-buildpackage -Ppkg.cysignals.pari\`"
	echo "********************************************************************************"
	exit 0
fi

cp -pr "/usr/share/doc/python-cysignals-doc/examples/$testname" "$ADTTMP"

cd "$ADTTMP/$testname"

make check

exit 0
