#!/bin/sh -e

#debug=1

if [ "$ADTTMP" = "" ] ; then
  ADTTMP=`mktemp -d /tmp/smalt-test.XXXXXX`
fi
cd $ADTTMP
cp -a /usr/share/doc/smalt/test/* $ADTTMP
gunzip *.py.gz data/*.bam.gz

TESTS="splitReads_test.py
       results_split_test.py
       ouform_cigar_test.py
       sample_test.py
       cigar_test.py
       mthread_test.py"

# since libbambamc is available we can dafely run all tests
TESTS=`ls *_test.py`

ln -s /usr/lib/smalt/test/sequenceReverseComplement_test .
for tst in $TESTS ; do
    if [ $debug ] ; then
        echo "Testing $tst ..."
    fi
    if [ "$tst" = "xali_test.py" ] ; then
        if [ $debug ] ; then
            echo "xali_test.py is using smalt built with different compile options"
            echo "lets try, whether the test also runs with plain smalt"
            echo "This fails with:"
            echo "   ERROR: wrong CIGAR string '44M44S' (target:'44M1X1M42S')"
        fi
        #ln -s /usr/bin/smalt smalt_Xali_test
        #python $tst
        #rm -f smalt_Xali_test
    else
        python $tst
    fi
done

