Skip to content

Commit 90e5eb5

Browse files
committed
test: Run go vet with -source flag in newer releases
This should hopefully eliminate some false positives. golang/go#20514
1 parent 795551a commit 90e5eb5

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

test/test-govet.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ function run-test()
1414
ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd .. && pwd )" # dir!
1515
cd "${ROOT}"
1616

17+
GO_VERSION=($(go version))
18+
1719
function simplify-gocase() {
1820
if grep 'case _ = <-' "$1"; then
1921
return 1 # 'case _ = <- can be simplified to: case <-'
@@ -30,7 +32,12 @@ function token-coloncheck() {
3032
}
3133

3234
for file in `find . -maxdepth 3 -type f -name '*.go' -not -path './old/*' -not -path './tmp/*'`; do
33-
run-test go vet "$file" || fail_test "go vet did not pass" # since it doesn't output an ok message on pass
35+
if [[ -z $(echo "${GO_VERSION[2]}" | grep -E 'go1.2|go1.3|go1.4|go1.5|go1.6|go1.7|go1.8') ]]; then
36+
run-test go vet "$file" || fail_test "go vet did not pass" # since it doesn't output an ok message on pass
37+
else
38+
# workaround go vet issues by adding the new -source flag
39+
run-test go vet -source "$file" || fail_test "go vet -source did not pass"
40+
fi
3441
run-test grep 'log.' "$file" | grep '\\n"' && fail_test 'no newline needed in log.Printf()' # no \n needed in log.Printf()
3542
run-test simplify-gocase "$file"
3643
run-test token-coloncheck "$file"

0 commit comments

Comments
 (0)