Created
June 12, 2015 09:41
-
-
Save gerhard/f768e89b16b850237e6e to your computer and use it in GitHub Desktop.
bash-autotest
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
#!/usr/bin/env bash | |
[ -z "$DEBUG" ] || set -x | |
main() { | |
resolve_dependencies | |
if [[ "$@" =~ watch ]] | |
then | |
autotest | |
else | |
test_all | |
fi | |
} | |
resolve_dependencies() { | |
[[ "$(brew list)" =~ fsw ]] || brew install fsw | |
go get github.com/progrium/basht | |
} | |
autotest() { | |
local file | |
fsw --latency 0.2 -e 'support' share/snatch test | while read file | |
do | |
is_test_file? "$file" || file="test/${file##*/}_test.bash" | |
test_one "$file" | |
date | |
done | |
} | |
is_test_file?() { | |
local file | |
file="$1" | |
[[ "$file" =~ _test.bash$ ]] | |
} | |
test_all() { | |
basht test/*_test.bash | |
} | |
test_one() { | |
local file | |
file="$1" | |
[ -f "$file" ] && basht "$file" | |
} | |
main "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment