]> Cypherpunks repositories - gostls13.git/commit
cmd/go: do not build test packages unnecessarily during go vet
authorRuss Cox <rsc@golang.org>
Fri, 10 May 2019 01:56:53 +0000 (21:56 -0400)
committerRuss Cox <rsc@golang.org>
Wed, 15 May 2019 17:02:43 +0000 (17:02 +0000)
commit38431f1044880b936e35034ded19a6a8bc9faa21
tree9de98cc604960d43148bd86f1190315d5320b601
parentba23fa483379deb6c5f22e150679bedde95c69c5
cmd/go: do not build test packages unnecessarily during go vet

Vet needs export data for the imports of the package it is analyzing.
Vet does not need export data for the package itself, since vet will
do its own type checking. Assuming that vet is just as good as the compiler
at detecting invalid programs, don't run the compiler unnecessarily.

This especially matters for tests without external test files or for
which the external test files do not import the test-augmented original
package. In that case, the test-augmented original package need not
be compiled at all.

Cuts time for 'go clean -cache && go vet -x cmd/compile/internal/ssa'
from 7.6r 24.3u 2.8s to 3.5r 8.5u 1.9s, by not running the compiler
on the augmented test package.

There is still more to be done here - if we do need to build a
test-augmented package, we rerun cgo unnecessarily.
But this is a big help.

Cuts time for 'go vet std cmd' by about 30%.

For #31916.

Change-Id: If6136b4d384f1da77aed90b43f1a6b95f09b5d86
Reviewed-on: https://go-review.googlesource.com/c/go/+/176438
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/cmd/go/go_test.go
src/cmd/go/internal/work/action.go
src/cmd/go/internal/work/exec.go