#!/bin/sh -e

pkg=r-cran-afex

if [ "$ADTTMP" = "" ] ; then
  ADTTMP=`mktemp -d /tmp/${pkg}-test.XXXXXX`
fi
cd $ADTTMP
cp -a /usr/share/doc/${pkg}/tests/* $ADTTMP
find . -name "*.gz" -exec gunzip \{\} \;
for runtest in `ls *.R` ; do
   LC_ALL=C R --no-save < $runtest >/dev/null
   if [ ! $? ] ; then
     echo "Test ${runtest} failed"
     exit 1
   else
     echo "Test ${runtest} passed"
   fi
done
rm -rf $ADTTMP/*
