• Russ Cox's avatar
    cmd/go: run vet automatically during go test · 0d188752
    Russ Cox authored
    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: 's avatarRob Pike <r@golang.org>
    Reviewed-by: 's avatarDavid Crawshaw <crawshaw@golang.org>
    0d188752
Name
Last commit
Last update
.github Loading commit data...
api Loading commit data...
doc Loading commit data...
lib/time Loading commit data...
misc Loading commit data...
src Loading commit data...
test Loading commit data...
.gitattributes Loading commit data...
.gitignore Loading commit data...
AUTHORS Loading commit data...
CONTRIBUTING.md Loading commit data...
CONTRIBUTORS Loading commit data...
LICENSE Loading commit data...
PATENTS Loading commit data...
README.md Loading commit data...
favicon.ico Loading commit data...
robots.txt Loading commit data...