Unit testing

- verbose unit testing to help flod tinderbox in displaying the results.
This commit is contained in:
Federico Hernandez 2012-09-11 22:38:40 +02:00
parent 8cd43ce2b2
commit 31bbc0ea2f
2 changed files with 51 additions and 33 deletions

View file

@ -10,7 +10,8 @@ set (test_SRCS autocomplete.t color.t config.t date.t directory.t dom.t
duration.t file.t i18n.t json.t list.t nibbler.t path.t rx.t duration.t file.t i18n.t json.t list.t nibbler.t path.t rx.t
t.t t2.t taskmod.t tdb2.t text.t uri.t util.t view.t json_test) t.t t2.t taskmod.t tdb2.t text.t uri.t util.t view.t json_test)
add_custom_target (test ./run_all DEPENDS ${test_SRCS} task_executable add_custom_target (test ./run_all --verbose
DEPENDS ${test_SRCS} task_executable
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/test) WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/test)
add_custom_target (build_tests DEPENDS ${test_SRCS} add_custom_target (build_tests DEPENDS ${test_SRCS}

View file

@ -1,39 +1,56 @@
#! /bin/bash #! /bin/sh
if [ x"$1" = x"--verbose" ];
then
for i in *.t *.t.exe
do
echo '#' $i
./$i > test.log 2>&1
while read LINE
do
echo $LINE
done < test.log
rm test.log
done
else
date > all.log date > all.log
# Perl is used here to get the time in seconds
# because 'date +%s' isn't supported on Solaris.
STARTEPOCH=`perl -e 'print time'` STARTEPOCH=`perl -e 'print time'`
VRAMSTEG=/usr/local/bin/vramsteg VRAMSTEG=`which vramsteg`
BAR=0 BAR=0
if [ -x $VRAMSTEG ]; then if [ -x "$VRAMSTEG" ]; then
BAR=1 BAR=1
COUNT=0 COUNT=0
TOTAL=$(ls *.t | wc -l) TOTAL=`ls *.t | wc -l`
START=$($VRAMSTEG --now) START=`$VRAMSTEG --now`
fi fi
for i in *.t *.t.exe for i in *.t *.t.exe
do do
echo '#' $i >>all.log echo '#' $i >>all.log
if [ $BAR == 1 ]; then if [ $BAR -eq 1 ]; then
$VRAMSTEG --label 'All tests' --min 0 --max $TOTAL --current $COUNT --percentage --start $START --estimate $VRAMSTEG --label 'All tests' --min 0 --max $TOTAL --current $COUNT --percentage --start $START --estimate
COUNT=$[COUNT + 1] COUNT=`expr $COUNT + 1`
fi fi
./$i >> all.log 2>&1 ./$i >> all.log 2>&1
done done
if [ $BAR == 1 ]; then if [ $BAR -eq 1 ]; then
$VRAMSTEG --remove $VRAMSTEG --remove
fi fi
date >> all.log date >> all.log
ENDEPOCH=`perl -e 'print time'` ENDEPOCH=`perl -e 'print time'`
RUNTIME=`expr $ENDEPOCH - $STARTEPOCH`
RUNTIME=$(($ENDEPOCH - $STARTEPOCH)) printf "Pass: %5d\n" `grep -c '^ok' all.log`
printf "Fail: %5d\n" `grep -c '^not' all.log`
printf "Pass: %5d\n" $(grep -c ^ok all.log) printf "Skipped: %5d\n" `grep -c '^skip' all.log`
printf "Fail: %5d\n" $(grep -c ^not all.log)
printf "Skipped: %5d\n" $(grep -c ^skip all.log)
printf "Runtime: %5d seconds\n" $RUNTIME printf "Runtime: %5d seconds\n" $RUNTIME
fi