#!/bin/bash
#
# Check that existing manualtest for files that are being commited still build
# They can break when the API changes
#
QMAKE=qmake
$QMAKE --version 2>&1 | grep 3.3 > /dev/null
if [ $? -eq 0 ] ; then
    QMAKE=qmake-qt4
fi
dir=`dirname $0`
for file in `git diff-index --name-only HEAD | grep .cpp` ; do
    file=`echo $file | sed -e 's/src\///g' -e 's/.cpp//g'`
    if [ ! -d $dir/../autotests/$file ] ; then
        file=`echo $file | sed -e 's/.*\///g'`;
    fi
    if [ -d $dir/../manualtests/$file ] ; then
        echo "--checking manualtest (should still build): $file--"
        cd "$dir/../../manualtests/$file/";
        $QMAKE;
        make --quiet
        if [ $? != 0 ] ; then
            echo "--Manualtest build failed, fix failure before commiting--";
            exit 1
        fi
        echo "--checking manualtest: $file done--"
    fi
done

