Add a simple bashfmt test
If someone ever made a bashfmt script, that would be a lovely hack!
This commit is contained in:
1
test.sh
1
test.sh
@@ -14,6 +14,7 @@ diff <(tail -n +$start AUTHORS | sort) <(tail -n +$start AUTHORS)
|
|||||||
|
|
||||||
./test/test-gofmt.sh
|
./test/test-gofmt.sh
|
||||||
./test/test-yamlfmt.sh
|
./test/test-yamlfmt.sh
|
||||||
|
./test/test-bashfmt.sh
|
||||||
go test
|
go test
|
||||||
echo running go vet # since it doesn't output an ok message on pass
|
echo running go vet # since it doesn't output an ok message on pass
|
||||||
go vet && echo PASS
|
go vet && echo PASS
|
||||||
|
|||||||
31
test/test-bashfmt.sh
Executable file
31
test/test-bashfmt.sh
Executable file
@@ -0,0 +1,31 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# check for any bash files that aren't properly formatted
|
||||||
|
# TODO: this is hardly exhaustive
|
||||||
|
|
||||||
|
set -o errexit
|
||||||
|
set -o nounset
|
||||||
|
set -o pipefail
|
||||||
|
|
||||||
|
ROOT=$(dirname "${BASH_SOURCE}")/..
|
||||||
|
|
||||||
|
cd "${ROOT}"
|
||||||
|
|
||||||
|
find_files() {
|
||||||
|
git ls-files | grep -e '\.sh$' -e '\.bash$'
|
||||||
|
}
|
||||||
|
|
||||||
|
bad_files=$(
|
||||||
|
for i in $(find_files); do
|
||||||
|
# search for more than one leading space, to ensure we use tabs
|
||||||
|
if grep -q '^ ' "$i"; then
|
||||||
|
echo "$i"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
)
|
||||||
|
|
||||||
|
if [[ -n "${bad_files}" ]]; then
|
||||||
|
echo 'FAIL'
|
||||||
|
echo 'The following bash files are not properly formatted:'
|
||||||
|
echo "${bad_files}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
Reference in New Issue
Block a user