#!/bin/sh
# autopkgtest check: build and run with default test data
# Author: Tatiana Malygina <merlettaia@gmail.com>

set -e

pkg=metastudent

if [ "$AUTOPKGTEST_TMP" = "" ] ; then
  AUTOPKGTEST_TMP=$(mktemp -d /tmp/${pkg}-test.XXXXXX)
  trap "rm -rf $AUTOPKGTEST_TMP" 0 INT QUIT ABRT PIPE TERM
fi

cd $AUTOPKGTEST_TMP

cp -a /usr/share/doc/${pkg}/examples/* .
find . -type f -name "*.gz" -exec gunzip \{\} \;
for lnk in `find . -type l -name "*.gz"` ; do
    ln -s `basename $(readlink $lnk) .gz` `echo $lnk | sed 's/\.gz$//'`
    rm $lnk
done

# call example from man:
metastudent -i test.fasta -o test.result.new --temp-dir=$AUTOPKGTEST_TMP
[ -z $(cmp -s test.result.BPO.txt test.result.new.BPO.txt) ]
[ -z $(cmp -s test.result.MFO.txt test.result.new.MFO.txt) ]
[ -z $(cmp -s test.result.CCO.txt test.result.new.CCO.txt) ]
