#!/bin/sh -e

pkgname=plumber
debname=r-cran-plumber

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 timeout test on i386, upstream says the same as well
# https://github.com/rstudio/plumber/issues/832#issuecomment-933716968

if [ "$hostarch" = "i386" ] ; then
       rm -f testthat/test-plumber-run.R
fi

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

