#!/bin/sh
# Alternative shell script to test Mathomatic that doesn't require the make utility.
# Just run this while in the tests directory with "./t"
# to see if Mathomatic runs properly on your system.
# After reading in and executing the Mathomatic scripts in "all.in",
# it does a diff between the output of the test and the expected output.
# If no differences are reported, "All tests passed" is displayed.

# Usage: ./t [ mathomatic_executable_to_test ]

if [ "$1" != "" ]
then
	MATHOMATICPATH="$1"
else
MATHOMATICPATH="../mathomatic"
if [ ! -x "$MATHOMATICPATH" ]
then
	MATHOMATICPATH=mathomatic
fi
fi

echo
echo Testing $MATHOMATICPATH
TESTOUT=`mktemp /tmp/test.XXXXXXXXXX` || exit 1
time -p "$MATHOMATICPATH" -t all 0<&- >$TESTOUT && diff -u all.out $TESTOUT && echo && echo All tests passed. && rm $TESTOUT && exit 0
echo Test failed.
echo Errors are in $TESTOUT
exit 1
