#!/bin/sh -e

pkgname=ensembldb
debname=r-bioc-ensembldb

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 *

# Remove tests requiring not yet packaged dataset
rm `grep -l EnsDb.Hsapiens.v86 testthat/*`
sed -i '/EnsDb.Hsapiens.v86/d' testthat.R
#  ... unfortunately this does not help since other tests are using the database via the defined edb variable

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