Skip to content

Commit

Permalink
test: Run go vet with -source flag in newer releases
Browse files Browse the repository at this point in the history
This should hopefully eliminate some false positives.
golang/go#20514
  • Loading branch information
purpleidea committed May 29, 2017
1 parent 795551a commit 424122d
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion test/test-govet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ function run-test()
ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd .. && pwd )" # dir!
cd "${ROOT}"

GO_VERSION=($(go version))

function simplify-gocase() {
if grep 'case _ = <-' "$1"; then
return 1 # 'case _ = <- can be simplified to: case <-'
Expand All @@ -30,7 +32,12 @@ function token-coloncheck() {
}

for file in `find . -maxdepth 3 -type f -name '*.go' -not -path './old/*' -not -path './tmp/*'`; do
run-test go vet "$file" || fail_test "go vet did not pass" # since it doesn't output an ok message on pass
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+)
run-test go vet -source "$file" || fail_test "go vet -source did not pass"
else
run-test go vet "$file" || fail_test "go vet did not pass" # since it doesn't output an ok message on pass
fi
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 token-coloncheck "$file"
Expand Down

0 comments on commit 424122d

Please sign in to comment.