#!/bin/sh
# autopkgtest check: Run test data through Gubbins
# Author: Sascha Steinbiss <satta@debian.org>
# Reviewed-By: Étienne Mollier <emollier@debian.org>
set -e
# This is expected to run in autopkgtest context.
CURDIR="$(pwd)"
WORKDIR="$(mktemp -d)"
HOME="$WORKDIR"
export HOME
trap "rm -rf $WORKDIR" 0 INT QUIT ABRT PIPE TERM
cd "$WORKDIR"

# Note several pathological datasets will trigger gubbins to return
# error without being symptomatic of an actual crash.
cp "$CURDIR/python/gubbins/tests/data/bootstrapping_test.aln" .
cp "$CURDIR/python/gubbins/tests/data/masking_multiple.aln" .
cp "$CURDIR/python/gubbins/tests/data/mislabelled.multiple_recombinations.aln" .
cp "$CURDIR/tests/data/no_recombinations.aln" .
cp "$CURDIR/tests/data/one_recombination.aln" .
cp "$CURDIR/tests/data/recombination_at_root/recombination_at_root.aln" .
cp "$CURDIR/tests/data/small_phylip_file.aln" .

for f in *.aln
do
	echo "##### $f #####"
	# See Github issue #442 for the iqtree tree builder.
	# [1]: https://github.com/nickjcroucher/gubbins/issues/442
	run_gubbins --tree-builder iqtree $f
done
