The check was running in the loop that read source files in, much before
any of the other checks ran. Vetxonly makes vet exit early, but after
all the source files have been read.
To fix this, simply run the buildtag check along with all the other
checks that get run on specific syntax tree nodes.
Add a cmd/go test with go test -a, to ensure that the issue as reported
is fixed.
Fixes #26102.
Change-Id: If6e3b9418ffa8166c0f982668b0d10872283776a
Reviewed-on: https://go-review.googlesource.com/121395
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
tg.runFail("test", "vetfail/...")
tg.grepStderr(`Printf format %d`, "did not diagnose bad Printf")
tg.grepStdout(`ok\s+vetfail/p2`, "did not run vetfail/p2")
+
+ // Use -a so that we need to recompute the vet-specific export data for
+ // vetfail/p1.
+ tg.run("test", "-a", "vetfail/p2")
+ tg.grepStderrNot(`invalid.*constraint`, "did diagnose bad build constraint in vetxonly mode")
}
func TestTestVetRebuild(t *testing.T) {
+// +build !foo-bar
+
package p1
import "fmt"
file: parsedFile,
dead: make(map[ast.Node]bool),
}
- checkBuildTag(file)
files = append(files, file)
}
if len(astFiles) == 0 {
}
}
for _, file := range files {
+ checkBuildTag(file)
file.checkers = chk
if file.file != nil {
file.walkFile(file.name, file.file)