test: Run go vet across whole packages not individual files

The golang tooling is quite deficient, in that it makes it quite
difficult to get the tools to do_the_right_thing, without ample wrapping
of bash scripting. Go vet was finding issues because it didn't have the
full context available. Hopefully this package level context is
sufficient for now. It still lacks inter-package context though.
This commit is contained in:
James Shubin
2017-05-29 14:13:03 -04:00
parent f4bb066737
commit 1fbe72b52d

View File

@@ -31,13 +31,25 @@ function token-coloncheck() {
return 0 return 0
} }
for file in `find . -maxdepth 3 -type f -name '*.go' -not -path './old/*' -not -path './tmp/*'`; do # loop through directories in an attempt to scan each go package
for dir in `find . -maxdepth 5 -type d -not -path './old/*' -not -path './old' -not -path './tmp/*' -not -path './tmp' -not -path './.*' -not -path './vendor/*'`; do
match="$dir/*.go"
#echo "match is: $match"
if ! ls $match &>/dev/null; then
#echo "skipping: $match"
continue # no *.go files found
fi
#echo "matching: $match"
if [[ -z $(echo "${GO_VERSION[2]}" | grep -E 'go1.2|go1.3|go1.4|go1.5|go1.6|go1.7|go1.8') ]]; then if [[ -z $(echo "${GO_VERSION[2]}" | grep -E 'go1.2|go1.3|go1.4|go1.5|go1.6|go1.7|go1.8') ]]; then
# workaround go vet issues by adding the new -source flag (go1.9+) # workaround go vet issues by adding the new -source flag (go1.9+)
run-test go vet -source "$file" || fail_test "go vet -source did not pass" echo run-test go vet -source "$match" || fail_test "go vet -source did not pass pkg"
else else
run-test go vet "$file" || fail_test "go vet did not pass" # since it doesn't output an ok message on pass echo run-test go vet "$match" || fail_test "go vet did not pass pkg" # since it doesn't output an ok message on pass
fi fi
done
# loop through individual *.go files
for file in `find . -maxdepth 3 -type f -name '*.go' -not -path './old/*' -not -path './tmp/*'`; do
run-test grep 'log.' "$file" | grep '\\n"' && fail_test 'no newline needed in log.Printf()' # no \n needed in log.Printf() run-test grep 'log.' "$file" | grep '\\n"' && fail_test 'no newline needed in log.Printf()' # no \n needed in log.Printf()
run-test simplify-gocase "$file" run-test simplify-gocase "$file"
run-test token-coloncheck "$file" run-test token-coloncheck "$file"