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

set -e

pkg=profphd-utils

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

cd $ADTTMP

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

# NOTE: following commands were used because convert_seq works in interactive 
# mode. Each `\n` means enter and corresponds to moving forward to next command.
# Thus, following calls emulate interactive mode.
# As stated in man page, program writes output to STDOUT.
# It means that in normal situation no errors should be produced.

echo "1ppt.hssp\nm\n\n\n\n" | convert_seq
[ -s 1ppt.msf ]

echo "1ppt.hssp\ny\n\n\n\n" | convert_seq
[ -s 1ppt.phy ]
