#!/bin/sh -e

pkg=r-cran-testthat
if [ "$AUTOPKGTEST_TMP" = "" ] ; then
  AUTOPKGTEST_TMP=`mktemp -d /tmp/${pkg}-test.XXXXXX`
fi
cd $AUTOPKGTEST_TMP
cp -a /usr/share/doc/${pkg}/tests .
cd tests

# Somehow 0 byte files are not propageted into the package :-(
touch testthat/reporters/silent.txt
mkdir -p testthat/test-path-present/tests/testthat
touch testthat/test-path-present/tests/testthat/empty
mkdir -p testthat/test-path-missing
touch testthat/test-path-missing/empty

find . -name "*.gz" -exec gunzip \{\} \;
# Delete tests depending from devtools since this is not (yet) packaged
#if grep -qR devtools * ; then
#    rm -f `grep -lR devtools *`
#fi

LC_ALL=C.UTF-8 R --no-save < testthat.R

rm -fr $AUTOPKGTEST_TMP/*
