#!/bin/sh -e

pkg=graphlan
if [ "$AUTOPKGTEST_TMP" = "" ] ; then
  AUTOPKGTEST_TMP=`mktemp -d /tmp/${pkg}-test.XXXXXX`
fi
cd $AUTOPKGTEST_TMP
cp -a /usr/share/doc/${pkg}/examples/* $AUTOPKGTEST_TMP
find . -name "*.gz" -exec gunzip \{\} \;
for testdir in `find . -mindepth 1 -maxdepth 1 -type d` ; do
    cd $testdir
    for tscript in `ls *.sh | sort` ; do
        if grep -q export2graphlan $tscript ; then
            echo "Test script $testdir/$tscript requires export2graphlan which is not available."
        else
            echo "Running test script $testdir/$tscript ."
            sh $tscript
        fi
    done
    cd ..
done
rm -rf $AUTOPKGTEST_TMP/*
