From aafe14ebc46027f0ce0cf4a2326f51bf0fc51b04 Mon Sep 17 00:00:00 2001 From: toddouska Date: Thu, 9 Aug 2012 16:42:18 -0700 Subject: [PATCH] add pre-commit hook and tests, put into autogen --- autogen.sh | 1 + commit-tests.sh | 34 ++++++++++++++++++++++++++++++++++ pre-commit.sh | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 69 insertions(+) create mode 100755 commit-tests.sh create mode 100755 pre-commit.sh diff --git a/autogen.sh b/autogen.sh index 09f9a6dae..b8fc82510 100755 --- a/autogen.sh +++ b/autogen.sh @@ -4,3 +4,4 @@ # autoreconf -ivf -Wall +ln -s -f ../../pre-commit.sh .git/hooks/pre-commit diff --git a/commit-tests.sh b/commit-tests.sh new file mode 100755 index 000000000..a1879f707 --- /dev/null +++ b/commit-tests.sh @@ -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 diff --git a/pre-commit.sh b/pre-commit.sh new file mode 100755 index 000000000..3413e954a --- /dev/null +++ b/pre-commit.sh @@ -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