Use up-to-date tests and run in test directory test_script
authorSami Rämö <sami.ramo@ixonos.com>
Wed, 26 May 2010 08:02:29 +0000 (11:02 +0300)
committerSami Rämö <sami.ramo@ixonos.com>
Wed, 26 May 2010 08:04:36 +0000 (11:04 +0300)
 - Reviewed by Ville

 - delete unit test binaries and run qmake &  make for
   tests.pro so unit tests run are always up-to-date

 - run each unit test in it's directory so test finds
   it's test data placed in it's directory

scripts/run_unit_tests.sh
tests/map/ownlocationitem/ownlocationitem.pro
tests/ui/friendlist/friendlist [deleted file]
tests/ui/friendlist/friendlist.pro
tests/user/user.pro

index 4462ce5..7af810e 100755 (executable)
@@ -31,24 +31,52 @@ if [[ -d $REPORT_PATH && -d $UNIT_TESTS_ROOT_DIR ]]; then
     # find all test .pro files pahts, cut .pro extension
     UNIT_TEST_PROJECTS=(`find $UNIT_TESTS_ROOT_DIR_ABSOLUTE | egrep .pro$ | sed -e s/.pro//g`)
 
+    echo "###################################################"
+    echo "All unit test executables will be deleted"
+    echo "and qmake + make will be run for root tests.pro"
+    echo "###################################################"
+    echo ""
+
+    # remove all unit test binaries
+    for BINARY in "${UNIT_TEST_PROJECTS[@]}"
+    do
+        # remove only if file really exists
+        if [ -a $BINARY ]; then
+            rm $BINARY
+        fi
+    done
+
+    # run qmake
+    cd $UNIT_TESTS_ROOT_DIR_ABSOLUTE
+    qmake -r
+    make
+    cd -
+
+    echo ""
+    echo "###################################################"
+    echo "Executing tests..."
+    echo "###################################################"
+
     # run tests
-    for project in "${UNIT_TEST_PROJECTS[@]}"
+    for PROJECT in "${UNIT_TEST_PROJECTS[@]}"
     do
         # do not try to test the root tests.pro project
-        if [ $project != "$UNIT_TESTS_ROOT_DIR_ABSOLUTE/tests" ]; then
+        if [ $PROJECT != "$UNIT_TESTS_ROOT_DIR_ABSOLUTE/tests" ]; then
             # check if unit test file is found and is executable
-            if [ -x $project ]; then
-                echo ""
+            if [ -x $PROJECT ]; then
+                # go to unit test directory
+                cd "`echo $PROJECT | grep --perl-regexp -o .*\(?=/\)`"
                 # run unit test, save to temp file, ignore strerr stream
-                $project -silent -o $REPORT_PATH_ABSOLUTE/$TEMP_REPORT_FILE 2> /dev/null
+                $PROJECT -silent -o $REPORT_PATH_ABSOLUTE/$TEMP_REPORT_FILE 2>&1 | grep -v "atk_object_set_name..assertion"
+                cd - > /dev/null
                 # print to screen and append to summary
                 cat $REPORT_PATH_ABSOLUTE/$TEMP_REPORT_FILE
                 cat $REPORT_PATH_ABSOLUTE/$TEMP_REPORT_FILE >> $REPORT_PATH_ABSOLUTE/$REPORT_FILE
                 echo "" >> $REPORT_PATH_ABSOLUTE/$REPORT_FILE
             else
                 # save path of missing test to temporary file
-                missing=(`echo $project | sed -e s,$UNIT_TESTS_ROOT_DIR_ABSOLUTE,,g`)
-                echo "$missing" >> "$REPORT_PATH_ABSOLUTE/$TEMP_FILE_EXEC_NOT_FOUND"
+                MISSING=(`echo $PROJECT | sed -e s,$UNIT_TESTS_ROOT_DIR_ABSOLUTE,,g`)
+                echo "$MISSING" >> "$REPORT_PATH_ABSOLUTE/$TEMP_FILE_EXEC_NOT_FOUND"
             fi
         fi
     done
@@ -75,8 +103,8 @@ if [[ -d $REPORT_PATH && -d $UNIT_TESTS_ROOT_DIR ]]; then
     fi
 
     # check if unit test output contained any qDebug or qWarning prints
-    debugs=$(egrep -c "(QDEBUG|QWARN)" $REPORT_PATH_ABSOLUTE/$REPORT_FILE)
-    if [ $debugs -ge 1 ]; then
+    DEBUG_COUNT=$(egrep -c "(QDEBUG|QWARN)" $REPORT_PATH_ABSOLUTE/$REPORT_FILE)
+    if [ $DEBUG_COUNT -ge 1 ]; then
         echo ""
         # print message in red and bold
         echo -e "\E[31m\E[1mDisable debug output from unit tests so test output stays readable!!!"
index 55efc20..79f2237 100644 (file)
@@ -4,7 +4,6 @@
 CONFIG += qtestlib
 QT += network
 TEMPLATE = app
-TARGET = ownlocation
 DEPENDPATH += .
 INCLUDEPATH += . \
     ../../../src/
diff --git a/tests/ui/friendlist/friendlist b/tests/ui/friendlist/friendlist
deleted file mode 100755 (executable)
index 9af5ca8..0000000
Binary files a/tests/ui/friendlist/friendlist and /dev/null differ
index 0ffd36d..ae941ea 100644 (file)
@@ -1,4 +1,5 @@
 CONFIG += qtestlib
+DEFINES += QT_NO_DEBUG_OUTPUT
 INCLUDEPATH += . \
     ../../../src/
 HEADERS += ../../../src/ui/friendlistview.h \
index 0644b33..9f07a0d 100644 (file)
@@ -7,6 +7,7 @@ TEMPLATE = app
 TARGET = 
 DEPENDPATH += .
 INCLUDEPATH += .
+DEFINES += QT_NO_DEBUG_OUTPUT
 
 # Input
 HEADERS += ../../src/user/user.h