Skip to content

Instantly share code, notes, and snippets.

@gerhard
Created June 12, 2015 09:41
Show Gist options
  • Save gerhard/f768e89b16b850237e6e to your computer and use it in GitHub Desktop.
Save gerhard/f768e89b16b850237e6e to your computer and use it in GitHub Desktop.
bash-autotest
#!/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