#!/bin/sh -e

pkg=figtree

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/* .
gunzip -r *

# Problem: figtree creates graphical output and requires user interaction to end
# Hack around: start figtree in background and kill all figtree processes started by the current user
# xvfb-run --auto-servernum
# figtree HA_continuous_MCC.tre HA_discrete_MCC.tre 

# Still testing around a way to export and save the tree without user interaction.
figtree -graphic PDF HA_continuous_MCC.tree HA_continuous_MCC.pdf
figtree -graphic PNG -width 320 -height 320 HA_continuous_MCC.tree HA_continuous_MCC.png

#sleep 10
#kill -9 `ps aux | grep -w "^${USER}.*figtree" | grep -v "0:0[0-9] grep " | grep -v "0:0[0-9] ps " | sed "s/^${USER}[[:space:]]\+\([0-9]\+\)[[:space:]]\+.*/\1/"`
