Created
December 5, 2016 20:05
-
-
Save stantonk/09227e9f32984858cebf589f0387004d to your computer and use it in GitHub Desktop.
Run unittests as a pre-push hook to avoid merging code that fails tests.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
################################################################################ | |
# Use as a global mercurial/git pre commit or pre push hook to detect the type | |
# of project and run unittests before allowing a commit or push to a remote | |
# repository. | |
# | |
# Handy so that you don't have to remember to add test running hooks to every | |
# repo clone/fork you have. | |
################################################################################ | |
echo "run-test-hooks executing..." | |
cmd="" | |
if [ -e "pom.xml" ]; | |
then | |
cmd="mvn clean -U test" | |
fi | |
if [ -e "manage.py" ]; | |
then | |
cmd="python manage.py test" | |
fi | |
if [ -e "setup.py" ]; | |
then | |
cmd="python -m unittest discover" | |
fi | |
$cmd | |
exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment