#!/bin/sh -e

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

if [ "$ADTTMP" = "" ] ; then
  ADTTMP=`mktemp -d /tmp/${pkg}-test.XXXXXX`
  trap "rm -rf $ADTTMP" 0 INT QUIT ABRT PIPE TERM
fi
cd $ADTTMP
cp -a /usr/share/doc/${pkg}/tests/* $ADTTMP
find . -name "*.gz" -exec gunzip \{\} \;
export LC_ALL=C
for test in *R
do
  R CMD BATCH ${test}
  if [ ! $? ] ; then
    echo "Test ${test} failed"
    exit 1
  else
    echo "Test ${test} passed"
  fi
  rm -f ${test}out .RData
done
