#!/bin/sh -e

# The expected outputs (*.Rout.save) are not expected to be identical, the
# "CRAN Package Check Results" show differences. So, we should probably not
# compare our output to the "expected" output. It produce a lot of false positive.
# https://cloud.r-project.org/web/checks/check_results_etm.html

export LC_ALL=C.UTF-8

debname=r-cran-etm

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 *
for testfile in *.R; do
    echo "BEGIN TEST $testfile"
    R --no-save < $testfile
done

