Created
September 6, 2012 09:24
-
-
Save jbarrett/3653648 to your computer and use it in GitHub Desktop.
A very simple loop to give constant feedback on tests v code. Stick it in a small tmux/screen pane for TDD goodness.
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
#!/bin/bash | |
# Wait for project changes, run tests, report. | |
RED=1 | |
GREEN=2 | |
testcmd="make test" | |
exclude='^\.git|.*swp' | |
function report { | |
tput bold | |
out=`$testcmd 2>&1` | |
if [ "$?" -eq "0" ] ; then | |
tput setaf $GREEN | |
echo "Tests passed... write more tests!" | |
else | |
tput setaf $RED | |
echo "$out" | tail -n 2 | |
fi | |
tput sgr0 | |
} | |
function main { | |
while inotifywait -r -e modify --exclude $exclude . &> /dev/null ; do | |
echo `date +%H:%M` "- files changed, testing..." | |
report | |
done | |
} | |
main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Wrote this for use with Perl projects, probably needs tweaking for other stuff.
Would be nice to derive 'exclude' from .gitignore