#!/bin/sh -e

pkgname=sf
debname=r-cran-sf

if [ "$AUTOPKGTEST_TMP" = "" ] ; then
    AUTOPKGTEST_TMP=`mktemp -d /tmp/${debname}-test.XXXXXX`
    trap "rm -rf $AUTOPKGTEST_TMP" 0 INT QUIT ABRT PIPE TERM
fi
cd $AUTOPKGTEST_TMP
cp -a /usr/share/doc/$debname/tests/* $AUTOPKGTEST_TMP
gunzip -r *

# Unfortunately its not possible to install packages afterwards - so s390x is excluded in list of architectures
#hostarch=$(dpkg-architecture -qDEB_HOST_ARCH)
## Ignore tests requiring lwgeom on s390x architecture where it is not available any more
#if [ "$hostarch" = "s390x" ] ; then
#  rm -f `grep -Rl lwgeom`
#else
#  apt-get install -y r-cran-lwgeom
#fi

# skip tests requiring r-cran-s2, see #976802
rm -f s2.R
for testfile in *.R; do
    echo "BEGIN TEST $testfile"
    LC_ALL=C R --no-save < $testfile
    echo "END TEST $testfile with result $?"
done

