tildefriends/tools/run-tests
2016-03-12 18:50:43 +00:00

37 lines
738 B
Bash
Executable File

#!/bin/bash
export ROOT=$(cd $(dirname ${BASH_SOURCE[0]})/..; pwd)
TMP=$ROOT/tmp
LOGS=$ROOT/logs
TESTS=$ROOT/tests
export SANDBOXOS=$ROOT/sandboxos
mkdir $TMP 2> /dev/null
mkdir $LOGS 2> /dev/null
REQUESTED_TESTS=$*
if [[ -z $REQUESTED_TESTS ]]; then
REQUESTED_TESTS=$(ls $TESTS/* | xargs basename -a)
fi
for NAME in $REQUESTED_TESTS; do
TEST=$TESTS/$NAME
echo -n "$(basename $TEST) "
rm -rf $TMP/*
pushd $TMP > /dev/null
export LOGDIR=$LOGS/$NAME
mkdir $LOGDIR 2> /dev/null
unbuffer $TEST > $LOGDIR/stdout.log 2> $LOGDIR/stderr.log
RESULT=$?
popd > /dev/null
if [[ $RESULT != 0 ]]; then
echo "FAILED (with exit code $RESULT)"
exit $RESULT
else
echo "SUCCESS"
fi
done
echo
echo "All tests completed successfully."