1
0
mirror of https://github.com/golang/go synced 2024-09-23 23:20:14 -06:00
go/misc
Russ Cox 0d18875252 cmd/go: run vet automatically during go test
This CL adds an automatic, limited "go vet" to "go test".
If the building of a test package fails, vet is not run.
If vet fails, the test is not run.
The goal is that users don't notice vet as part of the "go test"
process at all, until vet speaks up and says something important.
This should help users find real problems in their code faster
(vet can just point to them instead of needing to debug a
test failure) and expands the scope of what kinds of things
vet can help with.

The "go vet" runs in parallel with the linking of the test binary,
so for incremental builds it typically does not slow the overall
"go test" at all: there's spare machine capacity during the link.

all.bash has less spare machine capacity. This CL increases
the time for all.bash on my laptop from 4m41s to 4m48s (+2.5%)

To opt out for a given run, use "go test -vet=off".

The vet checks used during "go test" are a subset of the full set,
restricted to ones that are 100% correct and therefore acceptable
to make mandatory. In this CL, that set is atomic, bool, buildtags,
nilfunc, and printf. Including printf is debatable, but I want to
include it for now and find out what needs to be scaled back.
(It already found one real problem in package os's tests that
previous go vet os had not turned up.)
Now that we can rely on type information it may be that printf
should make its function-name-based heuristic less aggressive
and have a whitelist of known print/printf functions.
Determining the exact set for Go 1.10 is #18085.

Running vet also means that programs now have to type-check
with both cmd/compile and go/types in order to pass "go test".
We don't start vet until cmd/compile has built the test package,
so normally the added go/types check doesn't find anything.
However, there is at least one instance where go/types is more
precise than cmd/compile: declared and not used errors involving
variables captured into closures.

This CL includes a printf fix to os/os_test.go and many declared
and not used fixes in the race detector tests.

Fixes #18084.

Change-Id: I353e00b9d1f9fec540c7557db5653e7501f5e1c9
Reviewed-on: https://go-review.googlesource.com/74356
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2017-11-03 22:09:38 +00:00
..
android misc/android: don't let the Android exec wrapper hang indefinitely 2017-05-01 22:31:15 +00:00
arm all: make copyright headers consistent with one space after period 2016-05-02 13:43:18 +00:00
cgo cmd/go: run vet automatically during go test 2017-11-03 22:09:38 +00:00
chrome/gophertool all: link to https instead of http 2015-07-11 14:36:33 +00:00
git misc/git: Fix non-literal period in pre-commit grep 2016-02-26 19:06:38 +00:00
ios misc/ios: always kill lldb process when it hangs 2017-10-03 14:21:35 +00:00
linkcheck misc/linkcheck: better redirect handling, use meaningful exit code 2013-10-25 17:31:02 +03:00
nacl cmd/cover: preserve compiler directives in floating comments 2017-10-16 23:38:38 +00:00
sortac misc/sortac: add tool to sort the AUTHORS and CONTRIBUTORS files 2015-11-12 17:07:09 +00:00
swig all: make copyright headers consistent with one space after period 2016-05-02 13:43:18 +00:00
trace misc/trace: update trace-viewer 2017-08-25 15:50:29 +00:00
benchcmp all: use golang.org/x/... import paths 2014-11-10 09:15:57 +11:00
editors all: don't refer to code.google.com/p/go{,-wiki}/ 2015-02-06 14:41:47 +00:00