add pre-commit hook and tests, put into autogen

pull/1/head
toddouska 2012-08-09 16:42:18 -07:00
parent 80326fa1fa
commit aafe14ebc4
3 changed files with 69 additions and 0 deletions

View File

@ -4,3 +4,4 @@
#
autoreconf -ivf -Wall
ln -s -f ../../pre-commit.sh .git/hooks/pre-commit

34
commit-tests.sh 100755
View File

@ -0,0 +1,34 @@
#!/bin/bash
#commit-tests.sh
# make sure current config is ok
echo -e "\n\nTesting current config...\n\n"
make test;
RESULT=$?
[ $RESULT -ne 0 ] && echo -e "\n\nCurrent config make test failed" && exit 1
# make sure basic config is ok
echo -e "\n\nTesting basic config too...\n\n"
./configure;
RESULT=$?
[ $RESULT -ne 0 ] && echo -e "\n\nBasic config ./configure failed" && exit 1
make clean; make -j 8 test;
RESULT=$?
[ $RESULT -ne 0 ] && echo -e "\n\nBasic config make test failed" && exit 1
# make sure full config is ok
echo -e "\n\nTesting full config as well...\n\n"
./configure --enable-opensslExtra --enable-fastmath --enable-dtls --enable-aesgcm --enable-hc128;
RESULT=$?
[ $RESULT -ne 0 ] && echo -e "\n\nFull config ./configure failed" && exit 1
make clean; make -j 8 test;
RESULT=$?
[ $RESULT -ne 0 ] && echo -e "\n\nFull config make test failed" && exit 1
exit 0

34
pre-commit.sh 100755
View File

@ -0,0 +1,34 @@
#!/bin/sh
#
#
# Our "pre-commit" hook.
# save current config
echo "\n\nSaving current config\n\n"
cp config.status tmp.status
# stash modified files not part of this commit, don't test them
echo "\n\nStashing any modified files not part of commit\n\n"
git stash -q --keep-index
# do the commit tests
echo "\n\nRunning commit tests...\n\n"
./commit-tests.sh
RESULT=$?
# restore modified files not part of this commit
echo "\n\nPopping any stashed modified files not part of commit\n"
git stash pop -q
# restore current config
echo "\nRestoring current config\n"
mv tmp.status config.status
# don't show output incase error from above
./config.status >/dev/null 2>&1
make clean >/dev/null 2>&1
make -j 8 >/dev/null 2>&1
[ $RESULT -ne 0 ] && echo "\nOops, your commit failed\n" && exit 1
echo "\nCommit tests passed!\n"
exit 0