#!/bin/sh -e

pkg=jellyfish
if [ "$ADTTMP" = "" ] ; then
  ADTTMP=`mktemp -d /tmp/${pkg}-test.XXXXXX`
  trap "rm -rf $ADTTMP" 0 INT QUIT ABRT PIPE TERM
fi
cd $ADTTMP
mkdir tests
cp -a /usr/share/doc/jellyfish-examples/examples/* tests
sed -i "s#DIR=../bin#DIR=/usr/lib/${pkg}/bin#" tests/compat.sh
tests/generate_sequence.sh
sh tests/parallel_hashing.sh
sh tests/merge.sh
sh tests/bloom_filter.sh
echo "If you have a *really* powerful machine you can run this *really* big test by prepending"
echo "  'BIG=1' "
echo "before the following line"
sh tests/big.sh || true
sh tests/subset_hashing.sh
##############################################################################################
# It seems the following failures in the following test are planed ...
#
# $ jellyfish count -t 2 -g multi_file_fail_cmds -G 2 -C -m 15 -s 2M -o multi_file_fail.jf
# Command 'false' exited with error status 1
# Some generator commands failed
# $ jellyfish count -t 2 -C -m 15 -s 2M -o multi_file_fail.jf non_existent_sequence.fa
# terminate called after throwing an instance of 'std::runtime_error'
#   what():  Can't open file 'non_existent_sequence.fa'
# Aborted
#
sh tests/multi_file.sh
#############################################################################################
sh tests/bloom_counter.sh
sh tests/large_key.sh
/usr/lib/jellyfish/bin/test_all
