#!/bin/sh -e

pkgname=partykit
debname=r-cran-partykit

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 *
cd tests

hostarch=$(dpkg-architecture -qDEB_HOST_ARCH)
if [ "$hostarch" = "ppc64el" -o "$hostarch" = "arm64" -o "$hostarch" = "s390x" ] ; then
    rm bugfixes.R
fi

if apt-cache show r-cran-pmml > /dev/null 2>/dev/null ; then
  echo "Package r-cran-alluvial is available now - please remove the patch which excludes this package"
  exit -1
fi

for testfile in *.R; do
    echo "BEGIN TEST $testfile"
    LC_ALL=C.UTF-8 R --no-save < $testfile
done

