#!/bin/sh -e

oname=caret
pkg=r-cran-`echo $oname | tr '[A-Z]' '[a-z]'`

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

echo "FIXME: Do not delete tests requiring themis once r-cran-themis is available"
if apt-cache show r-cran-themis > /dev/null 2>/dev/null ; then
  echo "Package r-cran-themis is available now - do not remove the test requiring it any more"
  exit -1
fi
find . -name test_recipe_upsample.R -delete

LC_ALL=C R --no-save < testthat.R
