forked from user-none/arora
-
Notifications
You must be signed in to change notification settings - Fork 109
/
pre-commit_autotest
executable file
·33 lines (31 loc) · 1.04 KB
/
pre-commit_autotest
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
#!/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
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; ./$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 (1 second punishment)--"
sleep 1
fi
done