-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
"run-test" is a script, that performs all tests in the current work tree. This should be executed during development. "pre-commit" is a wrapper arount "run-test" such, that it can be symlinked to serve as a git pre-commit hook. Doing so will ensure to run all tests before commiting. The wrapper also stashes changes that will not be commited and restores them afterwards.
- Loading branch information
Showing
2 changed files
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/bin/bash | ||
|
||
# This script is a wrapper around the run-tests script. | ||
# It is highly recommended to link it as the git pre-commit hook via: | ||
|
||
# ln -s ../../pre-commit .git/hooks/pre-commit | ||
|
||
# The difference to the run-tests script is that this script stashes | ||
# unstaged changes before testing (see below). Thus only the changeset to be | ||
# commited will be tested. No worries, "git commit -a" will still work ;) | ||
# Stephan Kuschel, 2014 | ||
|
||
# Stash unstaged changes if and only if(!) necessary (=possible): | ||
# if you dont check that you might uninentionally apply an older stash, | ||
# because this if statement just makes sure, that there are changed to | ||
# be stashed on executing "git staph -q --keep-index". Otherwise it coud | ||
# happen, that git stash is executed, but no stash is created, because | ||
# there were no changes, that could be stashed. | ||
if git diff-index --quiet HEAD --; then | ||
#echo "pre-commit hook without stashing" | ||
./run-tests | ||
exitcode=$? | ||
else | ||
#echo "pre-commit hook with stashing" | ||
git stash -q --keep-index | ||
./run-tests | ||
exitcode=$? | ||
git stash pop -q | ||
fi | ||
|
||
|
||
exit $exitcode | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/bin/bash | ||
|
||
# run all tests and pep8 changes of this project. | ||
|
||
# For development, please see pre-commit for | ||
# instructions how to add this as a git pre-commit hook. | ||
|
||
# Stephan Kuschel, 2014 | ||
|
||
exitonfailure () { | ||
if [ $1 -ne 0 ]; then | ||
echo '"./run-tests" failed. Aborting.' | ||
exit $1 | ||
fi | ||
} | ||
|
||
# run actual tests | ||
nosetests | ||
exitonfailure $? | ||
|
||
pep8 postpic --statistics --count --show-source --ignore=W391 | ||
exitonfailure $? | ||
|
||
exit 0 | ||
|