public
Fork of icefox/arora
Description: Cross platform web browser
Homepage: http://arora.googlecode.com/
Clone URL: git://github.com/Arora/arora.git
arora / git_hooks / pre-commit_autotest
100755 34 lines (31 sloc) 1.053 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/bash
#
# Check that existing autotests for files that are being commited are not currently failing
#
QMAKE=qmake
$QMAKE --version 2>&1 | grep 3.3 > /dev/null
if [ $? -eq 0 ] ; then
QMAKE=qmake-qt4
fi
unset GIT_DIR
dir=`dirname $0`
for file in `git-diff-index --name-only HEAD | grep .cpp` ; do
file=`echo $file | sed -e s/.cpp//g -e 's/.*\///g'`
    if [ -d $dir/../autotests/$file ] ; then
echo "--checking autotest: $file--"
 
        tempfoo=`basename $0`
        TMPFILE=`mktemp -t ${tempfoo}.XXXXXXXXXX` || exit 1
        (cd "$dir/../../autotests/$file/"; $QMAKE; make --quiet; ./$file >> $TMPFILE)
        output=`cat $TMPFILE | grep ' failed,' | sed -e 's/.*passed, //g' -e 's/ failed.*//g'`
        if [ "${output}" != "0" ] ; then
echo "Autotests failed for $file, please fix before committing."
            cat $TMPFILE
            rm $TMPFILE
            exit 1
        fi
rm $TMPFILE
        echo "--checking autotest: $file done--"
    else
echo "--missing autotest: $file--"
    fi
done