Nicer testsuite runner
[bertos.git] / bertos / run_tests.sh
index 0e3401b2bf28229b3daa50ed65d4e324fa3d42d5..22309ecadbe5c74346cb7747dc506144d414bfe2 100755 (executable)
@@ -8,30 +8,36 @@
 # $Id$
 #
 
-
 VERBOSE=1
 
 CC=gcc
-CFLAGS="-W -Wall -Wextra -I. -Iemul -std=gnu99 -fno-builtin -D_DEBUG -D_TEST -DARCH=ARCH_EMUL"
+CFLAGS="-W -Wall -Wextra -Ibertos -Ibertos/emul -std=gnu99 -fno-builtin -D_DEBUG -D_TEST -DARCH=ARCH_EMUL"
 
 CXX=g++
 CXXFLAGS="$CFLAGS"
 
-TESTS=${TESTS:-`find . -name "*_test.*"`}
-
-for test in $TESTS; do
-       [ $VERBOSE -gt 0 ] && echo "Running $test..."
-       case "$test" in
-       *.cpp)
-               $CXX $CXXFLAGS $test -o test || exit 1
-               ./test || exit 1
-               rm -f test
-       ;;
-       *.c)
-               $CC $CFLAGS $test -o test || exit 1
-               ./test || exit 1
-               rm -f test
-       ;;
+TESTS=${TESTS:-`find . \
+       \( -name .svn -prune -o -name .git -prune -o -name .hg  -prune \) \
+       -o -name "*_test.c*" -print` }
+
+TESTOUT="testout"
+
+mkdir -p "$TESTOUT"
+
+for src in $TESTS; do
+       name="`basename $src | sed -e 's/\.cpp$//' -e 's/\.c$//'`"
+       exe="./$TESTOUT/$name"
+
+       case "$src" in
+       *.cpp) BUILDCMD="$CXX $CXXFLAGS $src -o $exe" ;;
+       *.c)   BUILDCMD="$CC  $CXXFLAGS $src -o $exe" ;;
        esac
+
+       [ $VERBOSE -gt 0 ] && echo "Building $name..."
+       $BUILDCMD 2>&1 | tee $name.build || echo "FAILED [BUILD]: $name"
+
+       [ $VERBOSE -gt 0 ] && echo "Running $name..."
+       $exe 2>&1 | tee $name.out || echo "FAILED [RUN]: $name"
+       #rm -f "$exe"
 done