Skip to content

Instantly share code, notes, and snippets.

@jbarrett
Created September 6, 2012 09:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jbarrett/3653648 to your computer and use it in GitHub Desktop.
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.
#!/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
@jbarrett
Copy link
Author

jbarrett commented Sep 6, 2012

Wrote this for use with Perl projects, probably needs tweaking for other stuff.

Would be nice to derive 'exclude' from .gitignore

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment