#!/bin/sh -e

oname=aroma.light
pkg=r-bioc-`echo $oname | tr '[A-Z]' '[a-z]'`

if [ "$ADTTMP" = "" ] ; then
  ADTTMP=`mktemp -d /tmp/${pkg}-test.XXXXXX`
fi
cd $ADTTMP
cp /usr/share/doc/$pkg/tests/* $ADTTMP
find . -name "*.gz" -exec gunzip \{\} \;
for runtest in `ls *.R` ; do
   if grep -q fitPrincipalCurve $runtest ; then
      # Full test would beed princurve which is not packaged yet
      # Just remove the code after this function was used from the test
      echo '*** strip test since r-cran-princurve is not available as Debian package ***'
      sed -i '/fitPrincipalCurve/,$d' $runtest
   fi
   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 *
