#!/bin/sh -e

if [ "$AUTOPKGTEST_TMP" = "" ] ; then
  AUTOPKGTEST_TMP=`mktemp -d /tmp/bedtools-test.XXXXXX`
  trap "rm -rf $AUTOPKGTEST_TMP" 0 INT QUIT ABRT PIPE TERM
fi

# Copy test suite there
cp -a /usr/share/bedtools/test $AUTOPKGTEST_TMP

# Link to genomes files
cd $AUTOPKGTEST_TMP

ln -s /usr/share/bedtools/genomes

# Enter the directory and run the tests
cd $AUTOPKGTEST_TMP/test

# Configure test suite to call bedtools test elements installed on the OS,
# instead of the default fetching in the source tree.
export DATA="/usr/share/bedtools/data"
export BT="/usr/bin/bedtools"
export htsutil="$BT htsutil"
sh test.sh
