Improve the tests script

This commit is contained in:
Pierre Pronchery 2015-05-11 00:02:23 +02:00
parent 194a99958e
commit b118257b55

View File

@ -17,6 +17,7 @@
#variables
[ -n "$OBJDIR" ] || OBJDIR="./"
PROGNAME="tests.sh"
#executables
DATE="date"
@ -25,42 +26,41 @@ DATE="date"
#functions
#fail
_fail()
{
_run "$@" >> "$target"
}
#run
_run()
{
test="$1"
sep=
[ $# -eq 1 ] || sep=" "
shift
echo -n "$test:" 1>&2
(echo
echo "Testing: ./$test" "$@"
"./$test" "$@" 2>&1) >> "$target"
echo "Testing: $test" "$@"
"$OBJDIR$test" "$@") 2>&1
res=$?
if [ $res -ne 0 ]; then
echo " FAIL (error $res)" 1>&2
echo "Test: $test$sep$@: FAIL (error $res)"
echo " FAIL" 1>&2
else
echo "Test: $test$sep$@: PASS"
echo " PASS" 1>&2
fi
return $res
}
#test
_test()
{
test="$1"
shift
echo -n "$test:" 1>&2
(echo
echo "Testing: ./$test" "$@"
"./$test" "$@") >> "$target" 2>&1
_run "$@" >> "$target"
res=$?
if [ $res -ne 0 ]; then
echo " FAIL" 1>&2
FAILED="$FAILED $test(error $res)"
return 2
else
echo " PASS" 1>&2
return 0
fi
[ $res -eq 0 ] || FAILED="$FAILED $test(error $res)"
}