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
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)
add_custom_target (build_tests DEPENDS ${test_SRCS}

View file

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