#!/bin/sh
# script to execute unit tests for Curry
CURRYHOME=..
CURRYBIN=$CURRYHOME/bin

# use the right Curry system for the tests:
PATH=$CURRYBIN:$PATH
export PATH

TESTPARAMS="--window"
if [ "$1" = "--nogui" ] ; then
  TESTPARAMS=
fi

BACKEND=`$CURRYBIN/curry :set v0 :set -time :load Distribution :eval "putStrLn (curryRuntime ++ show curryRuntimeMajorVersion)" :quit 2> /dev/null`

# test for basic language features
TESTLANG="testFunctional testInfinite testHigher testNarr testNondet testCase testFCase testLetRec testRecords testNonLinearPattern testNonStrictUnif testFuncPattern testAsPattern"

# test for standard libraries
TESTLIBS="testPrelude testAbstractCurry testCombinatorial testDatabase testDirectory testDynamic testFlatCurryGoodies testFlatCurryXML testGlobal testGlobalVariable testInteger testIOExts testList testSetFunctions testSort testSystem testTraversal testArray testDequeue testFiniteMap testRedBlackTree testFormat testRegExp"

# additional library tests for PAKCS with various Prolog back ends:
TESTLIBSBACKEND=
case "$BACKEND" in
  sicstus3 ) TESTLIBSBACKEND="testIO testCLPB " ;;
  sicstus4 ) TESTLIBSBACKEND="testCLPB " ;;
  swi5     ) TESTLIBSBACKEND="testIO " ;;
esac

ALLTESTS="$TESTLANG $TESTLIBS $TESTLIBSBACKEND"

# clean up before
$CURRYBIN/cleancurry

# execute all unit tests:
echo "Executing unit tests for back end $BACKEND..."
$CURRYBIN/currytest $TESTPARAMS $ALLTESTS
