Fixed unit tests
[situare] / scripts / run_unit_tests.sh
index 2aa0cce..4462ce5 100755 (executable)
@@ -33,19 +33,23 @@ if [[ -d $REPORT_PATH && -d $UNIT_TESTS_ROOT_DIR ]]; then
 
     # run tests
     for project in "${UNIT_TEST_PROJECTS[@]}"
-    do 
-        if [ -f $project ]; then
-            echo ""
-            # run unit test, save to temp file, ignore strerr stream
-            $project -silent -o $REPORT_PATH_ABSOLUTE/$TEMP_REPORT_FILE 2> /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"
+    do
+        # do not try to test the root tests.pro project
+        if [ $project != "$UNIT_TESTS_ROOT_DIR_ABSOLUTE/tests" ]; then
+            # check if unit test file is found and is executable
+            if [ -x $project ]; then
+                echo ""
+                # run unit test, save to temp file, ignore strerr stream
+                $project -silent -o $REPORT_PATH_ABSOLUTE/$TEMP_REPORT_FILE 2> /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"
+            fi
         fi
     done
 
@@ -57,6 +61,10 @@ if [[ -d $REPORT_PATH && -d $UNIT_TESTS_ROOT_DIR ]]; then
         echo -e "###################################################\E[31m\E[1m" ## set red color & bold
         cat $REPORT_PATH_ABSOLUTE/$TEMP_FILE_EXEC_NOT_FOUND
         tput sgr0 # restore terminal defaults
+        echo ""
+        echo "Some possible causes:"
+        echo "  - project has set target name explicitly. Target name must be same as directory name"
+        echo "  - don't use shadow build system"
 
         # and save same list also to test summary file
         echo "" >> $REPORT
@@ -66,6 +74,15 @@ if [[ -d $REPORT_PATH && -d $UNIT_TESTS_ROOT_DIR ]]; then
         cat $REPORT_PATH_ABSOLUTE/$TEMP_FILE_EXEC_NOT_FOUND  >> $REPORT
     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
+        echo ""
+        # print message in red and bold
+        echo -e "\E[31m\E[1mDisable debug output from unit tests so test output stays readable!!!"
+        tput sgr0 # restore terminal defaults
+    fi
+
     # remove temporary files
     rm $REPORT_PATH_ABSOLUTE/temp_*.txt