test: Switch to goimports instead of gofmt

see https://github.com/purpleidea/mgmt/pull/256#issuecomment-346360414
This commit is contained in:
Guillaume Herail
2017-11-24 16:07:17 +01:00
committed by James Shubin
parent 3575d597f7
commit ac629404f4
4 changed files with 17 additions and 8 deletions

View File

@@ -22,9 +22,16 @@ find_files() {
git ls-files | grep '\.go$'
}
GOFMT="gofmt" # we prefer to not use the -s flag, which is pretty annoying...
# gofmt -s -l
GOFMT="gofmt"
bad_files=$(find_files | xargs $GOFMT -s -l)
if [[ -n "${bad_files}" ]]; then
fail_test "The following golang files are not properly formatted (gofmt -s -l): ${bad_files}"
fi
#goimports -l
GOFMT="goimports"
bad_files=$(find_files | xargs $GOFMT -l)
if [[ -n "${bad_files}" ]]; then
fail_test "The following golang files are not properly formatted: ${bad_files}"
fail_test "The following golang files are not properly formatted (goimports -l): ${bad_files}"
fi
echo 'PASS'