#!/bin/sh -e

pkgname=mice
debname=r-cran-mice

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

hostarch=$(dpkg-architecture -qDEB_HOST_ARCH)
# Ignore single some tests for i386 architecture
if [ "$hostarch" = "i386" ] ; then
  rm -f testthat/test-pool.r.squared.R \
        testthat/test-pool.R \
        testthat/test-mice.impute.panImpute.R \
        testthat/test-filter.R \
        testthat/test-D3.R \
        testthat/test-blots.R \
        testthat/test-tidiers.R \
        testthat/test-parlmice.R
fi

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

