#!/bin/sh -e

oname=xml2
pkg=r-cran-`echo $oname | tr [A-Z] [a-z]`

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

# FIXME: Hack around a problematic test
# One test results in
#       -- 1. Error: Searches with entities work (#241) (@test-xml_find.R#136)  --------
#       Can't find `tests/testthat` in current directory.
# The following circumvents this by some not so clean trick
mkdir testthat/tests
ln -s $(pwd)/testthat testthat/tests/testthat

LC_ALL=C R --no-save < testthat.R
rm -fr $AUTOPKGTEST_TMP/*
