#!/bin/sh -e

debname=r-cran-broom.helpers

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 *
cd tests

# There is no package r-cran-gtsummary available yet
echo "FIXME: Do not delete tests once r-cran-gtsummary is available"
if apt-cache show r-cran-gtsummary > /dev/null 2>/dev/null ; then
  echo "Package r-cran-gtsummary is available now - do not remove the test requiring it any more"
  exit -1
fi
for testfile in testthat/* ; do
    if grep -q gtsummary $testfile ; then
        rm $testfile
    fi
done

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

