#!/bin/sh -e

pkgname=afex
debname=r-cran-afex

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

echo "FIXME: Do not delete tests requiring MEMSS once r-cran-memss is available"
if apt-cache show r-cran-memss > /dev/null 2>/dev/null ; then
  echo "Package r-cran-memss is available now - do not remove the test requiring it any more"
  exit -1
else
  rm -f `grep -lR MEMSS`
fi

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